summaryrefslogtreecommitdiffstats
path: root/pkg/commands/loaders/commit_files_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/commands/loaders/commit_files_test.go')
-rw-r--r--pkg/commands/loaders/commit_files_test.go71
1 files changed, 71 insertions, 0 deletions
diff --git a/pkg/commands/loaders/commit_files_test.go b/pkg/commands/loaders/commit_files_test.go
new file mode 100644
index 000000000..a07390052
--- /dev/null
+++ b/pkg/commands/loaders/commit_files_test.go
@@ -0,0 +1,71 @@
+package loaders
+
+import (
+ "testing"
+
+ "github.com/jesseduffield/lazygit/pkg/commands/models"
+ "github.com/stretchr/testify/assert"
+)
+
+func TestGetCommitFilesFromFilenames(t *testing.T) {
+ tests := []struct {
+ testName string
+ input string
+ output []*models.CommitFile
+ }{
+ {
+ testName: "no files",
+ input: "",
+ output: []*models.CommitFile{},
+ },
+ {
+ testName: "one file",
+ input: "MM\x00Myfile\x00",
+ output: []*models.CommitFile{
+ {
+ Name: "Myfile",
+ ChangeStatus: "MM",
+ },
+ },
+ },
+ {
+ testName: "two files",
+ input: "MM\x00Myfile\x00M \x00MyOtherFile\x00",
+ output: []*models.CommitFile{
+ {
+ Name: "Myfile",
+ ChangeStatus: "MM",
+ },
+ {
+ Name: "MyOtherFile",
+ ChangeStatus: "M ",
+ },
+ },
+ },
+ {
+ testName: "three files",
+ input: "MM\x00Myfile\x00M \x00MyOtherFile\x00 M\x00YetAnother\x00",
+ output: []*models.CommitFile{
+ {
+ Name: "Myfile",
+ ChangeStatus: "MM",
+ },
+ {
+ Name: "MyOtherFile",
+ ChangeStatus: "M ",
+ },
+ {
+ Name: "YetAnother",
+ ChangeStatus: " M",
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.testName, func(t *testing.T) {
+ result := getCommitFilesFromFilenames(test.input)
+ assert.Equal(t, test.output, result)
+ })
+ }
+}