MCPcopy Index your code
hub / github.com/cli/cli / Test_editRun

Function Test_editRun

pkg/cmd/repo/edit/edit_test.go:169–338  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

167}
168
169func Test_editRun(t *testing.T) {
170 tests := []struct {
171 name string
172 opts EditOptions
173 httpStubs func(*testing.T, *httpmock.Registry)
174 wantsStderr string
175 wantsErr string
176 }{
177 {
178 name: "change name and description",
179 opts: EditOptions{
180 Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"),
181 Edits: EditRepositoryInput{
182 Homepage: sp("newURL"),
183 Description: sp("hello world!"),
184 },
185 },
186 httpStubs: func(t *testing.T, r *httpmock.Registry) {
187 r.Register(
188 httpmock.REST("PATCH", "repos/OWNER/REPO"),
189 httpmock.RESTPayload(200, `{}`, func(payload map[string]interface{}) {
190 assert.Equal(t, 2, len(payload))
191 assert.Equal(t, "newURL", payload["homepage"])
192 assert.Equal(t, "hello world!", payload["description"])
193 }))
194 },
195 },
196 {
197 name: "add and remove topics",
198 opts: EditOptions{
199 Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"),
200 AddTopics: []string{"topic1", "topic2"},
201 RemoveTopics: []string{"topic3"},
202 },
203 httpStubs: func(t *testing.T, r *httpmock.Registry) {
204 r.Register(
205 httpmock.REST("GET", "repos/OWNER/REPO/topics"),
206 httpmock.StringResponse(`{"names":["topic2", "topic3", "go"]}`))
207 r.Register(
208 httpmock.REST("PUT", "repos/OWNER/REPO/topics"),
209 httpmock.RESTPayload(200, `{}`, func(payload map[string]interface{}) {
210 assert.Equal(t, 1, len(payload))
211 assert.Equal(t, []interface{}{"topic2", "go", "topic1"}, payload["names"])
212 }))
213 },
214 },
215 {
216 name: "allow update branch",
217 opts: EditOptions{
218 Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"),
219 Edits: EditRepositoryInput{
220 AllowUpdateBranch: bp(true),
221 },
222 },
223 httpStubs: func(t *testing.T, r *httpmock.Registry) {
224 r.Register(
225 httpmock.REST("PATCH", "repos/OWNER/REPO"),
226 httpmock.RESTPayload(200, `{}`, func(payload map[string]interface{}) {

Callers

nothing calls this directly

Calls 15

VerifyMethod · 0.95
NewWithHostFunction · 0.92
RESTFunction · 0.92
RESTPayloadFunction · 0.92
StringResponseFunction · 0.92
GraphQLFunction · 0.92
TestFunction · 0.92
spFunction · 0.85
bpFunction · 0.85
EqualMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80

Tested by

no test coverage detected