summaryrefslogtreecommitdiffstats
path: root/pkg/commands
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-07-29 20:37:05 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-07-31 08:28:03 +0200
commit774df817fd7b3f8c1a08a41ad5d23b08ed24f0b0 (patch)
tree6f7940047ed20bbb75d1c25a154ccc2999824ee9 /pkg/commands
parent18903a7dde07a57a023649bf1eb87d3ce77b6347 (diff)
Add tests for setCommitMergedStatuses
The test for update-ref shows demonstrates a problem. See next commit for the fix.
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/git_commands/commit_loader_test.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/pkg/commands/git_commands/commit_loader_test.go b/pkg/commands/git_commands/commit_loader_test.go
index bcbc33c02..a281cb775 100644
--- a/pkg/commands/git_commands/commit_loader_test.go
+++ b/pkg/commands/git_commands/commit_loader_test.go
@@ -506,3 +506,50 @@ func TestCommitLoader_getConflictedCommitImpl(t *testing.T) {
})
}
}
+
+func TestCommitLoader_setCommitMergedStatuses(t *testing.T) {
+ type scenario struct {
+ testName string
+ commits []*models.Commit
+ ancestor string
+ expectedCommits []*models.Commit
+ }
+
+ scenarios := []scenario{
+ {
+ testName: "basic",
+ commits: []*models.Commit{
+ {Sha: "12345", Name: "1", Action: models.ActionNone, Status: models.StatusUnpushed},
+ {Sha: "67890", Name: "2", Action: models.ActionNone, Status: models.StatusPushed},
+ {Sha: "abcde", Name: "3", Action: models.ActionNone, Status: models.StatusPushed},
+ },
+ ancestor: "67890",
+ expectedCommits: []*models.Commit{
+ {Sha: "12345", Name: "1", Action: models.ActionNone, Status: models.StatusUnpushed},
+ {Sha: "67890", Name: "2", Action: models.ActionNone, Status: models.StatusMerged},
+ {Sha: "abcde", Name: "3", Action: models.ActionNone, Status: models.StatusMerged},
+ },
+ },
+ {
+ testName: "with update-ref",
+ commits: []*models.Commit{
+ {Sha: "12345", Name: "1", Action: models.ActionNone, Status: models.StatusUnpushed},
+ {Sha: "", Name: "", Action: todo.UpdateRef, Status: models.StatusNone},
+ {Sha: "abcde", Name: "3", Action: models.ActionNone, Status: models.StatusPushed},
+ },
+ ancestor: "deadbeef",
+ expectedCommits: []*models.Commit{
+ {Sha: "12345", Name: "1", Action: models.ActionNone, Status: models.StatusUnpushed},
+ {Sha: "", Name: "", Action: todo.UpdateRef, Status: models.StatusNone},
+ {Sha: "abcde", Name: "3", Action: models.ActionNone, Status: models.StatusMerged}, // Wrong, expect Pushed
+ },
+ },
+ }
+
+ for _, scenario := range scenarios {
+ t.Run(scenario.testName, func(t *testing.T) {
+ expectedCommits := setCommitMergedStatuses(scenario.ancestor, scenario.commits)
+ assert.Equal(t, scenario.expectedCommits, expectedCommits)
+ })
+ }
+}