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

Function Test_BaseRepo

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

Source from the content-addressed store, hash-verified

24)
25
26func 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 != "" {

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