summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-05-30 20:30:47 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-05-31 15:54:20 +0200
commit697157f5d57ef674eca2d2ee5236d6f2736b2f61 (patch)
tree12c4596e67d5360ed3e551e8960ea148ce590fe4 /pkg
parentee4b9d20b14d1b856fed3889f574a4e8f0fa661f (diff)
Add tests for Fetch
Diffstat (limited to 'pkg')
-rw-r--r--pkg/commands/git_commands/sync_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/pkg/commands/git_commands/sync_test.go b/pkg/commands/git_commands/sync_test.go
index 23058eb92..07fe8f932 100644
--- a/pkg/commands/git_commands/sync_test.go
+++ b/pkg/commands/git_commands/sync_test.go
@@ -92,3 +92,40 @@ func TestSyncPush(t *testing.T) {
})
}
}
+
+func TestSyncFetch(t *testing.T) {
+ type scenario struct {
+ testName string
+ opts FetchOptions
+ test func(oscommands.ICmdObj)
+ }
+
+ scenarios := []scenario{
+ {
+ testName: "Fetch in foreground",
+ opts: FetchOptions{Background: false},
+ test: func(cmdObj oscommands.ICmdObj) {
+ assert.True(t, cmdObj.ShouldLog())
+ assert.Equal(t, cmdObj.GetCredentialStrategy(), oscommands.PROMPT)
+ assert.Equal(t, cmdObj.Args(), []string{"git", "fetch"})
+ },
+ },
+ {
+ testName: "Fetch in background",
+ opts: FetchOptions{Background: true},
+ test: func(cmdObj oscommands.ICmdObj) {
+ assert.False(t, cmdObj.ShouldLog())
+ assert.Equal(t, cmdObj.GetCredentialStrategy(), oscommands.FAIL)
+ assert.Equal(t, cmdObj.Args(), []string{"git", "fetch"})
+ },
+ },
+ }
+
+ for _, s := range scenarios {
+ s := s
+ t.Run(s.testName, func(t *testing.T) {
+ instance := buildSyncCommands(commonDeps{})
+ s.test(instance.FetchCmdObj(s.opts))
+ })
+ }
+}