(t *testing.T)
| 351 | } |
| 352 | |
| 353 | func TestClientShowRefs(t *testing.T) { |
| 354 | tests := []struct { |
| 355 | name string |
| 356 | cmdExitStatus int |
| 357 | cmdStdout string |
| 358 | cmdStderr string |
| 359 | wantCmdArgs string |
| 360 | wantRefs []Ref |
| 361 | wantErrorMsg string |
| 362 | }{ |
| 363 | { |
| 364 | name: "show refs with one valid ref and one invalid ref", |
| 365 | cmdExitStatus: 128, |
| 366 | cmdStdout: "9ea76237a557015e73446d33268569a114c0649c refs/heads/valid", |
| 367 | cmdStderr: "fatal: 'refs/heads/invalid' - not a valid ref", |
| 368 | wantCmdArgs: `path/to/git show-ref --verify -- refs/heads/valid refs/heads/invalid`, |
| 369 | wantRefs: []Ref{{ |
| 370 | Hash: "9ea76237a557015e73446d33268569a114c0649c", |
| 371 | Name: "refs/heads/valid", |
| 372 | }}, |
| 373 | wantErrorMsg: "failed to run git: fatal: 'refs/heads/invalid' - not a valid ref", |
| 374 | }, |
| 375 | } |
| 376 | for _, tt := range tests { |
| 377 | t.Run(tt.name, func(t *testing.T) { |
| 378 | cmd, cmdCtx := createCommandContext(t, tt.cmdExitStatus, tt.cmdStdout, tt.cmdStderr) |
| 379 | client := Client{ |
| 380 | GitPath: "path/to/git", |
| 381 | commandContext: cmdCtx, |
| 382 | } |
| 383 | refs, err := client.ShowRefs(context.Background(), []string{"refs/heads/valid", "refs/heads/invalid"}) |
| 384 | assert.Equal(t, tt.wantCmdArgs, strings.Join(cmd.Args[3:], " ")) |
| 385 | assert.EqualError(t, err, tt.wantErrorMsg) |
| 386 | assert.Equal(t, tt.wantRefs, refs) |
| 387 | }) |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | func TestClientConfig(t *testing.T) { |
| 392 | tests := []struct { |
nothing calls this directly
no test coverage detected