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

Function Test_SmartBaseRepo

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

Source from the content-addressed store, hash-verified

109}
110
111func Test_SmartBaseRepo(t *testing.T) {
112 pu, _ := url.Parse("https://test.com/newowner/newrepo.git")
113
114 tests := []struct {
115 name string
116 remotes git.RemoteSet
117 override string
118 wantsErr bool
119 wantsName string
120 wantsOwner string
121 wantsHost string
122 tty bool
123 httpStubs func(*httpmock.Registry)
124 }{
125 {
126 name: "override with matching remote",
127 remotes: git.RemoteSet{
128 git.NewRemote("origin", "https://test.com/owner/repo.git"),
129 },
130 override: "test.com",
131 wantsName: "repo",
132 wantsOwner: "owner",
133 wantsHost: "test.com",
134 },
135 {
136 name: "override with matching remote and base resolution",
137 remotes: git.RemoteSet{
138 &git.Remote{Name: "origin",
139 Resolved: "base",
140 FetchURL: pu,
141 PushURL: pu},
142 },
143 override: "test.com",
144 wantsName: "newrepo",
145 wantsOwner: "newowner",
146 wantsHost: "test.com",
147 },
148 {
149 name: "override with matching remote and nonbase resolution",
150 remotes: git.RemoteSet{
151 &git.Remote{Name: "origin",
152 Resolved: "johnny/test",
153 FetchURL: pu,
154 PushURL: pu},
155 },
156 override: "test.com",
157 wantsName: "test",
158 wantsOwner: "johnny",
159 wantsHost: "test.com",
160 },
161 {
162 name: "override with no matching remote",
163 remotes: git.RemoteSet{
164 git.NewRemote("origin", "https://example.com/owner/repo.git"),
165 },
166 override: "test.com",
167 wantsErr: true,
168 },

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
SetHostsMethod · 0.95
SetActiveTokenMethod · 0.95
SetDefaultHostMethod · 0.95
VerifyMethod · 0.95
ResolverMethod · 0.95
NewRemoteFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
TestFunction · 0.92
SmartBaseRepoFuncFunction · 0.85
SetStdinTTYMethod · 0.80

Tested by

no test coverage detected