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