(t *testing.T)
| 375 | } |
| 376 | |
| 377 | func Test_removeRun_env(t *testing.T) { |
| 378 | tests := []struct { |
| 379 | name string |
| 380 | opts *DeleteOptions |
| 381 | host string |
| 382 | httpStubs func(*httpmock.Registry) |
| 383 | }{ |
| 384 | { |
| 385 | name: "delete environment secret", |
| 386 | opts: &DeleteOptions{ |
| 387 | SecretName: "cool_secret", |
| 388 | EnvName: "development", |
| 389 | }, |
| 390 | host: "github.com", |
| 391 | httpStubs: func(reg *httpmock.Registry) { |
| 392 | reg.Register(httpmock.WithHost(httpmock.REST("DELETE", "repos/owner/repo/environments/development/secrets/cool_secret"), "api.github.com"), |
| 393 | httpmock.StatusStringResponse(204, "No Content")) |
| 394 | }, |
| 395 | }, |
| 396 | { |
| 397 | name: "delete environment secret GHES", |
| 398 | opts: &DeleteOptions{ |
| 399 | SecretName: "cool_secret", |
| 400 | EnvName: "development", |
| 401 | }, |
| 402 | host: "example.com", |
| 403 | httpStubs: func(reg *httpmock.Registry) { |
| 404 | reg.Register(httpmock.WithHost(httpmock.REST("DELETE", "api/v3/repos/owner/repo/environments/development/secrets/cool_secret"), "example.com"), |
| 405 | httpmock.StatusStringResponse(204, "No Content")) |
| 406 | }, |
| 407 | }, |
| 408 | } |
| 409 | |
| 410 | for _, tt := range tests { |
| 411 | reg := &httpmock.Registry{} |
| 412 | tt.httpStubs(reg) |
| 413 | defer reg.Verify(t) |
| 414 | |
| 415 | ios, _, _, _ := iostreams.Test() |
| 416 | tt.opts.IO = ios |
| 417 | tt.opts.BaseRepo = func() (ghrepo.Interface, error) { |
| 418 | if tt.host != "" { |
| 419 | return ghrepo.FromFullNameWithHost("owner/repo", tt.host) |
| 420 | } |
| 421 | return ghrepo.FromFullName("owner/repo") |
| 422 | } |
| 423 | tt.opts.HttpClient = func() (*http.Client, error) { |
| 424 | return &http.Client{Transport: reg}, nil |
| 425 | } |
| 426 | tt.opts.Config = func() (gh.Config, error) { |
| 427 | return config.NewBlankConfig(), nil |
| 428 | } |
| 429 | |
| 430 | err := removeRun(tt.opts) |
| 431 | require.NoError(t, err) |
| 432 | } |
| 433 | } |
| 434 |
nothing calls this directly
no test coverage detected