(t *testing.T)
| 401 | } |
| 402 | |
| 403 | func TestNewGitClient(t *testing.T) { |
| 404 | tests := []struct { |
| 405 | name string |
| 406 | config gh.Config |
| 407 | executable string |
| 408 | wantAuthHosts []string |
| 409 | wantGhPath string |
| 410 | }{ |
| 411 | { |
| 412 | name: "creates git client", |
| 413 | config: defaultConfig(), |
| 414 | executable: filepath.Join("path", "to", "gh"), |
| 415 | wantAuthHosts: []string{"nonsense.com"}, |
| 416 | wantGhPath: filepath.Join("path", "to", "gh"), |
| 417 | }, |
| 418 | } |
| 419 | for _, tt := range tests { |
| 420 | t.Run(tt.name, func(t *testing.T) { |
| 421 | f := &cmdutil.Factory{} |
| 422 | f.Config = func() (gh.Config, error) { |
| 423 | if tt.config == nil { |
| 424 | return config.NewBlankConfig(), nil |
| 425 | } else { |
| 426 | return tt.config, nil |
| 427 | } |
| 428 | } |
| 429 | f.ExecutablePath = tt.executable |
| 430 | ios, _, _, _ := iostreams.Test() |
| 431 | f.IOStreams = ios |
| 432 | c := newGitClient(f) |
| 433 | assert.Equal(t, tt.wantGhPath, c.GhPath) |
| 434 | assert.Equal(t, ios.In, c.Stdin) |
| 435 | assert.Equal(t, ios.Out, c.Stdout) |
| 436 | assert.Equal(t, ios.ErrOut, c.Stderr) |
| 437 | }) |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | func defaultConfig() *ghmock.ConfigMock { |
| 442 | cfg := config.NewFromString("") |
nothing calls this directly
no test coverage detected