MCPcopy
hub / github.com/cli/cli / TestFromFullName

Function TestFromFullName

internal/ghrepo/repo_test.go:118–222  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

116}
117
118func TestFromFullName(t *testing.T) {
119 tests := []struct {
120 name string
121 input string
122 hostOverride string
123 wantOwner string
124 wantName string
125 wantHost string
126 wantErr error
127 }{
128 {
129 name: "OWNER/REPO combo",
130 input: "OWNER/REPO",
131 wantHost: "github.com",
132 wantOwner: "OWNER",
133 wantName: "REPO",
134 wantErr: nil,
135 },
136 {
137 name: "too few elements",
138 input: "OWNER",
139 wantErr: errors.New(`expected the "[HOST/]OWNER/REPO" format, got "OWNER"`),
140 },
141 {
142 name: "too many elements",
143 input: "a/b/c/d",
144 wantErr: errors.New(`expected the "[HOST/]OWNER/REPO" format, got "a/b/c/d"`),
145 },
146 {
147 name: "blank value",
148 input: "a/",
149 wantErr: errors.New(`expected the "[HOST/]OWNER/REPO" format, got "a/"`),
150 },
151 {
152 name: "with hostname",
153 input: "example.org/OWNER/REPO",
154 wantHost: "example.org",
155 wantOwner: "OWNER",
156 wantName: "REPO",
157 wantErr: nil,
158 },
159 {
160 name: "full URL",
161 input: "https://example.org/OWNER/REPO.git",
162 wantHost: "example.org",
163 wantOwner: "OWNER",
164 wantName: "REPO",
165 wantErr: nil,
166 },
167 {
168 name: "SSH URL",
169 input: "git@example.org:OWNER/REPO.git",
170 wantHost: "example.org",
171 wantOwner: "OWNER",
172 wantName: "REPO",
173 wantErr: nil,
174 },
175 {

Callers

nothing calls this directly

Calls 7

FromFullNameFunction · 0.85
RunMethod · 0.65
RepoHostMethod · 0.65
ErrorfMethod · 0.65
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected