MCPcopy
hub / github.com/jesseduffield/lazygit / TestSyncFetch

Function TestSyncFetch

pkg/commands/git_commands/sync_test.go:114–152  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

112}
113
114func TestSyncFetch(t *testing.T) {
115 type scenario struct {
116 testName string
117 fetchAllConfig bool
118 test func(*oscommands.CmdObj)
119 }
120
121 scenarios := []scenario{
122 {
123 testName: "Fetch in foreground (all=false)",
124 fetchAllConfig: false,
125 test: func(cmdObj *oscommands.CmdObj) {
126 assert.True(t, cmdObj.ShouldLog())
127 assert.Equal(t, cmdObj.GetCredentialStrategy(), oscommands.PROMPT)
128 assert.False(t, cmdObj.ShouldSuppressOutputUnlessError())
129 assert.Equal(t, cmdObj.Args(), []string{"git", "fetch", "--no-write-fetch-head"})
130 },
131 },
132 {
133 testName: "Fetch in foreground (all=true)",
134 fetchAllConfig: true,
135 test: func(cmdObj *oscommands.CmdObj) {
136 assert.True(t, cmdObj.ShouldLog())
137 assert.Equal(t, cmdObj.GetCredentialStrategy(), oscommands.PROMPT)
138 assert.False(t, cmdObj.ShouldSuppressOutputUnlessError())
139 assert.Equal(t, cmdObj.Args(), []string{"git", "fetch", "--all", "--no-write-fetch-head"})
140 },
141 },
142 }
143
144 for _, s := range scenarios {
145 t.Run(s.testName, func(t *testing.T) {
146 instance := buildSyncCommands(commonDeps{})
147 instance.UserConfig().Git.FetchAll = s.fetchAllConfig
148 task := gocui.NewFakeTask()
149 s.test(instance.FetchCmdObj(task))
150 })
151 }
152}
153
154func TestSyncFetchBackground(t *testing.T) {
155 type scenario struct {

Callers

nothing calls this directly

Calls 10

NewFakeTaskFunction · 0.92
buildSyncCommandsFunction · 0.85
ShouldLogMethod · 0.80
GetCredentialStrategyMethod · 0.80
ArgsMethod · 0.80
UserConfigMethod · 0.80
testMethod · 0.80
FetchCmdObjMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected