(t *testing.T)
| 112 | } |
| 113 | |
| 114 | func 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 | |
| 154 | func TestSyncFetchBackground(t *testing.T) { |
| 155 | type scenario struct { |
nothing calls this directly
no test coverage detected