MCPcopy
hub / github.com/cli/cli / Test_setRun_org

Function Test_setRun_org

pkg/cmd/variable/set/set_test.go:316–418  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

314}
315
316func Test_setRun_org(t *testing.T) {
317 tests := []struct {
318 name string
319 opts *SetOptions
320 httpStubs func(*httpmock.Registry)
321 wantVisibility shared.Visibility
322 wantRepositories []int64
323 }{
324 {
325 name: "create org variable",
326 opts: &SetOptions{
327 OrgName: "UmbrellaCorporation",
328 Visibility: shared.All,
329 },
330 httpStubs: func(reg *httpmock.Registry) {
331 reg.Register(httpmock.REST("POST", "orgs/UmbrellaCorporation/actions/variables"),
332 httpmock.StatusStringResponse(201, `{}`))
333 },
334 },
335 {
336 name: "update org variable",
337 opts: &SetOptions{
338 OrgName: "UmbrellaCorporation",
339 Visibility: shared.All,
340 },
341 httpStubs: func(reg *httpmock.Registry) {
342 reg.Register(httpmock.REST("POST", "orgs/UmbrellaCorporation/actions/variables"),
343 httpmock.StatusStringResponse(409, `{}`))
344 reg.Register(httpmock.REST("PATCH", "orgs/UmbrellaCorporation/actions/variables/cool_variable"),
345 httpmock.StatusStringResponse(204, `{}`))
346 },
347 },
348 {
349 name: "create org variable with selected visibility",
350 opts: &SetOptions{
351 OrgName: "UmbrellaCorporation",
352 Visibility: shared.Selected,
353 RepositoryNames: []string{"birkin", "UmbrellaCorporation/wesker"},
354 },
355 httpStubs: func(reg *httpmock.Registry) {
356 reg.Register(httpmock.GraphQL(`query MapRepositoryNames\b`),
357 httpmock.StringResponse(`{"data":{"repo_0001":{"databaseId":1},"repo_0002":{"databaseId":2}}}`))
358 reg.Register(httpmock.REST("POST", "orgs/UmbrellaCorporation/actions/variables"),
359 httpmock.StatusStringResponse(201, `{}`))
360 },
361 wantRepositories: []int64{1, 2},
362 },
363 {
364 name: "update org variable with selected visibility",
365 opts: &SetOptions{
366 OrgName: "UmbrellaCorporation",
367 Visibility: shared.Selected,
368 RepositoryNames: []string{"birkin", "UmbrellaCorporation/wesker"},
369 },
370 httpStubs: func(reg *httpmock.Registry) {
371 reg.Register(httpmock.GraphQL(`query MapRepositoryNames\b`),
372 httpmock.StringResponse(`{"data":{"repo_0001":{"databaseId":1},"repo_0002":{"databaseId":2}}}`))
373 reg.Register(httpmock.REST("POST", "orgs/UmbrellaCorporation/actions/variables"),

Callers

nothing calls this directly

Calls 12

RegisterMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
StatusStringResponseFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
TestFunction · 0.92
FromFullNameFunction · 0.92
NewBlankConfigFunction · 0.92
EqualMethod · 0.80
setRunFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected