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

Function Test_SmartBaseRepo

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

Source from the content-addressed store, hash-verified

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

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