MCPcopy
hub / github.com/cli/cli / Test_SmartBaseRepo

Function Test_SmartBaseRepo

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

Source from the content-addressed store, hash-verified

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

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