mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-17 21:18:31 +02:00
Add tests for Fetch
This commit is contained in:
parent
ee4b9d20b1
commit
697157f5d5
@ -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))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user