(t *testing.T)
| 440 | } |
| 441 | |
| 442 | func TestNewGitClient(t *testing.T) { |
| 443 | tests := []struct { |
| 444 | name string |
| 445 | config gh.Config |
| 446 | executable string |
| 447 | wantAuthHosts []string |
| 448 | wantGhPath string |
| 449 | }{ |
| 450 | { |
| 451 | name: "creates git client", |
| 452 | config: defaultConfig(), |
| 453 | executable: filepath.Join("path", "to", "gh"), |
| 454 | wantAuthHosts: []string{"nonsense.com"}, |
| 455 | wantGhPath: filepath.Join("path", "to", "gh"), |
| 456 | }, |
| 457 | } |
| 458 | for _, tt := range tests { |
| 459 | t.Run(tt.name, func(t *testing.T) { |
| 460 | f := &cmdutil.Factory{} |
| 461 | f.Config = func() (gh.Config, error) { |
| 462 | if tt.config == nil { |
| 463 | return config.NewMockConfig(), nil |
| 464 | } else { |
| 465 | return tt.config, nil |
| 466 | } |
| 467 | } |
| 468 | f.ExecutablePath = tt.executable |
| 469 | ios, _, _, _ := iostreams.Test() |
| 470 | f.IOStreams = ios |
| 471 | c := newGitClient(f) |
| 472 | assert.Equal(t, tt.wantGhPath, c.GhPath) |
| 473 | assert.Equal(t, ios.In, c.Stdin) |
| 474 | assert.Equal(t, ios.Out, c.Stdout) |
| 475 | assert.Equal(t, ios.ErrOut, c.Stderr) |
| 476 | }) |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | func defaultConfig() *ghmock.ConfigMock { |
| 481 | cfg := config.NewMockConfigFromString("") |
nothing calls this directly
no test coverage detected