MCPcopy
hub / github.com/cli/cli / TestClientDeleteLocalTag

Function TestClientDeleteLocalTag

git/client_test.go:1234–1271  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1232}
1233
1234func TestClientDeleteLocalTag(t *testing.T) {
1235 tests := []struct {
1236 name string
1237 cmdExitStatus int
1238 cmdStdout string
1239 cmdStderr string
1240 wantCmdArgs string
1241 wantErrorMsg string
1242 }{
1243 {
1244 name: "delete local tag",
1245 wantCmdArgs: `path/to/git tag -d v1.0`,
1246 },
1247 {
1248 name: "git error",
1249 cmdExitStatus: 1,
1250 cmdStderr: "git error message",
1251 wantCmdArgs: `path/to/git tag -d v1.0`,
1252 wantErrorMsg: "failed to run git: git error message",
1253 },
1254 }
1255 for _, tt := range tests {
1256 t.Run(tt.name, func(t *testing.T) {
1257 cmd, cmdCtx := createCommandContext(t, tt.cmdExitStatus, tt.cmdStdout, tt.cmdStderr)
1258 client := Client{
1259 GitPath: "path/to/git",
1260 commandContext: cmdCtx,
1261 }
1262 err := client.DeleteLocalTag(context.Background(), "v1.0")
1263 assert.Equal(t, tt.wantCmdArgs, strings.Join(cmd.Args[3:], " "))
1264 if tt.wantErrorMsg == "" {
1265 assert.NoError(t, err)
1266 } else {
1267 assert.EqualError(t, err, tt.wantErrorMsg)
1268 }
1269 })
1270 }
1271}
1272
1273func TestClientDeleteLocalBranch(t *testing.T) {
1274 tests := []struct {

Callers

nothing calls this directly

Calls 5

DeleteLocalTagMethod · 0.95
createCommandContextFunction · 0.85
EqualMethod · 0.80
JoinMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected