(t *testing.T)
| 20 | ) |
| 21 | |
| 22 | func Test_BaseRepo(t *testing.T) { |
| 23 | tests := []struct { |
| 24 | name string |
| 25 | remotes git.RemoteSet |
| 26 | override string |
| 27 | wantsErr bool |
| 28 | wantsName string |
| 29 | wantsOwner string |
| 30 | wantsHost string |
| 31 | }{ |
| 32 | { |
| 33 | name: "matching remote", |
| 34 | remotes: git.RemoteSet{ |
| 35 | git.NewRemote("origin", "https://nonsense.com/owner/repo.git"), |
| 36 | }, |
| 37 | wantsName: "repo", |
| 38 | wantsOwner: "owner", |
| 39 | wantsHost: "nonsense.com", |
| 40 | }, |
| 41 | { |
| 42 | name: "no matching remote", |
| 43 | remotes: git.RemoteSet{ |
| 44 | git.NewRemote("origin", "https://test.com/owner/repo.git"), |
| 45 | }, |
| 46 | wantsErr: true, |
| 47 | }, |
| 48 | { |
| 49 | name: "override with matching remote", |
| 50 | remotes: git.RemoteSet{ |
| 51 | git.NewRemote("origin", "https://test.com/owner/repo.git"), |
| 52 | }, |
| 53 | override: "test.com", |
| 54 | wantsName: "repo", |
| 55 | wantsOwner: "owner", |
| 56 | wantsHost: "test.com", |
| 57 | }, |
| 58 | { |
| 59 | name: "override with no matching remote", |
| 60 | remotes: git.RemoteSet{ |
| 61 | git.NewRemote("origin", "https://nonsense.com/owner/repo.git"), |
| 62 | }, |
| 63 | override: "test.com", |
| 64 | wantsErr: true, |
| 65 | }, |
| 66 | } |
| 67 | |
| 68 | for _, tt := range tests { |
| 69 | t.Run(tt.name, func(t *testing.T) { |
| 70 | rr := &remoteResolver{ |
| 71 | readRemotes: func() (git.RemoteSet, error) { |
| 72 | return tt.remotes, nil |
| 73 | }, |
| 74 | getConfig: func() (gh.Config, error) { |
| 75 | cfg := &ghmock.ConfigMock{} |
| 76 | cfg.AuthenticationFunc = func() gh.AuthConfig { |
| 77 | authCfg := &config.AuthConfig{} |
| 78 | hosts := []string{"nonsense.com"} |
| 79 | if tt.override != "" { |
nothing calls this directly
no test coverage detected