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

Function TestClientDeleteLocalTag

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

Source from the content-addressed store, hash-verified

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