MCPcopy Create free account
hub / github.com/cli/cli / Test_BaseRepo

Function Test_BaseRepo

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

Source from the content-addressed store, hash-verified

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

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