@@ -80,3 +80,42 @@ func TestGenerate(t *testing.T) {
80
80
})
81
81
}
82
82
}
83
+
84
+ func TestGenerateForTestRepo (t * testing.T ) {
85
+ type TestCase struct {
86
+ name string
87
+ options * option.Options
88
+ Project string
89
+ ResultFile string
90
+ wantErr error
91
+ }
92
+
93
+ var tests = []TestCase {
94
+ {
95
+ name : "whatchanged-community/test-first-commit" ,
96
+ Project : "https://github.com/whatchanged-community/test-first-commit.git" ,
97
+ ResultFile : "fixtures/test-first-commit.md" ,
98
+ options : & option.Options {
99
+ Version : []string {"HEAD~" },
100
+ },
101
+ },
102
+ }
103
+
104
+ for _ , tt := range tests {
105
+ t .Run (tt .name , func (t * testing.T ) {
106
+ w := & bytes.Buffer {}
107
+ if err := Generate (context .Background (), tt .Project , w , tt .options ); err != tt .wantErr {
108
+ t .Errorf ("Generate() error = %v, wantErr %v" , err , tt .wantErr )
109
+ return
110
+ }
111
+
112
+ if b , err := ioutil .ReadFile (tt .ResultFile ); err != nil {
113
+ t .Errorf ("Generate() error = %v, wantErr %v" , err , tt .wantErr )
114
+ } else {
115
+ if gotW := w .String (); gotW != string (b ) {
116
+ assert .Equal (t , w .String (), string (b ), tt .name )
117
+ }
118
+ }
119
+ })
120
+ }
121
+ }
0 commit comments