MCPcopy
hub / github.com/cli/cli / Test_BaseRepo

Function Test_BaseRepo

pkg/cmd/factory/default_test.go:22–108  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

20)
21
22func 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 != "" {

Callers

nothing calls this directly

Calls 13

SetHostsMethod · 0.95
SetActiveTokenMethod · 0.95
SetDefaultHostMethod · 0.95
ResolverMethod · 0.95
NewRemoteFunction · 0.92
BaseRepoFuncFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
BaseRepoMethod · 0.65
RepoNameMethod · 0.65
RepoOwnerMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected