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