Skip to content

Commit c186190

Browse files
authored
Fix test for commit
Expected commit message could have files in different order.
1 parent a96779f commit c186190

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

commit_test.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package lazycommit
22

33
import (
4+
"strings"
45
"testing"
56

67
gitconfig "github.com/go-git/go-git/v5/config"
@@ -39,12 +40,16 @@ func TestCommit(t *testing.T) {
3940
t.Fatal(err)
4041
}
4142

42-
wantMsg := `Update files
43+
wantHeader := "Update files"
44+
wantBodyLines := []string{"- Create test.txt", "- Create test2.txt"}
4345

44-
- Create test.txt
45-
- Create test2.txt
46-
`
47-
if msg != wantMsg {
48-
t.Errorf("expected commit message to be %q, got %q", wantMsg, msg)
46+
if !strings.HasPrefix(msg, wantHeader) {
47+
t.Errorf("expected commit message to start with %q, got %q", wantHeader, msg)
48+
}
49+
50+
for _, line := range wantBodyLines {
51+
if !strings.Contains(msg, line) {
52+
t.Errorf("expected commit message to contain %q, got %q", line, msg)
53+
}
4954
}
5055
}

0 commit comments

Comments
 (0)