MCPcopy Create free account
hub / github.com/cli/cli / TestClientDeleteLocalTag

Function TestClientDeleteLocalTag

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

Source from the content-addressed store, hash-verified

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