(t *testing.T)
| 314 | } |
| 315 | |
| 316 | func 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"), |
nothing calls this directly
no test coverage detected