(t *testing.T)
| 501 | } |
| 502 | |
| 503 | func TestNewGitClient(t *testing.T) { |
| 504 | tests := []struct { |
| 505 | name string |
| 506 | config gh.Config |
| 507 | executable string |
| 508 | wantAuthHosts []string |
| 509 | wantGhPath string |
| 510 | }{ |
| 511 | { |
| 512 | name: "creates git client", |
| 513 | config: defaultConfig(), |
| 514 | executable: filepath.Join("path", "to", "gh"), |
| 515 | wantAuthHosts: []string{"nonsense.com"}, |
| 516 | wantGhPath: filepath.Join("path", "to", "gh"), |
| 517 | }, |
| 518 | } |
| 519 | for _, tt := range tests { |
| 520 | t.Run(tt.name, func(t *testing.T) { |
| 521 | f := &cmdutil.Factory{} |
| 522 | f.Config = func() (gh.Config, error) { |
| 523 | if tt.config == nil { |
| 524 | return config.NewMockConfig(), nil |
| 525 | } else { |
| 526 | return tt.config, nil |
| 527 | } |
| 528 | } |
| 529 | f.ExecutablePath = tt.executable |
| 530 | ios, _, _, _ := iostreams.Test() |
| 531 | f.IOStreams = ios |
| 532 | c := newGitClient(f) |
| 533 | assert.Equal(t, tt.wantGhPath, c.GhPath) |
| 534 | assert.Equal(t, ios.In, c.Stdin) |
| 535 | assert.Equal(t, ios.Out, c.Stdout) |
| 536 | assert.Equal(t, ios.ErrOut, c.Stderr) |
| 537 | }) |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | func defaultConfig() *ghmock.ConfigMock { |
| 542 | cfg := config.NewMockConfigFromString("") |
nothing calls this directly
no test coverage detected