Skip to content

Commit 803d4cd

Browse files
committed
test: add more test
1 parent 2dce123 commit 803d4cd

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

fixtures/test-first-commit.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Unreleased (2021-10-03)
2+
-----------------------
3+
4+
### 💪 Commits(1):
5+
6+
- [`c27085b`](https://github.com/whatchanged-community/test-first-commit/commit/c27085b7f485abcdad37b2be979090d8bc57135a) - Initial commit

whatchanged_test.go

+39
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,42 @@ func TestGenerate(t *testing.T) {
8080
})
8181
}
8282
}
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

Comments
 (0)