Skip to content

Commit

Permalink
Add test case for the commit with trailers
Browse files Browse the repository at this point in the history
Signed-off-by: Yoshiki Fujikane <[email protected]>
  • Loading branch information
ffjlabo committed Nov 8, 2024
1 parent b5089af commit ec9c267
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pkg/git/repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,25 @@ func TestCommitChanges(t *testing.T) {
require.Equal(t, 2, len(commits))
assert.Equal(t, "New commit with changes", commits[0].Message)

// Commit with trailers
trailers := map[string]string{
"test": "hoge",
}
changes2 := map[string][]byte{
"README.md": []byte("new-readme2"),
}
err = r.CommitChanges(ctx, "new-branch2", "New commit with changes and trailers", true, changes2, trailers)
require.NoError(t, err)

commits, err = r.ListCommits(ctx, "")
require.NoError(t, err)
require.Equal(t, 3, len(commits))
assert.Equal(t, "New commit with changes and trailers", commits[0].Message)

// Check the content of the latest commit
bytes, err := os.ReadFile(filepath.Join(r.dir, "README.md"))
require.NoError(t, err)
assert.Equal(t, string(changes["README.md"]), string(bytes))
assert.Equal(t, string(changes2["README.md"]), string(bytes))

bytes, err = os.ReadFile(filepath.Join(r.dir, "a/b/c/new.txt"))
require.NoError(t, err)
Expand Down

0 comments on commit ec9c267

Please sign in to comment.