MCPcopy Create free account
hub / github.com/github/gh-aw / TestGetMissingRequiredSecrets

Function TestGetMissingRequiredSecrets

pkg/cli/engine_secrets_test.go:419–614  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

417}
418
419func TestGetMissingRequiredSecrets(t *testing.T) {
420 t.Run("all secrets missing", func(t *testing.T) {
421 requirements := []SecretRequirement{
422 {Name: "SECRET1", Optional: false},
423 {Name: "SECRET2", Optional: false},
424 {Name: "SECRET3", Optional: false},
425 }
426 existingSecrets := map[string]struct {
427 }{}
428
429 missing := getMissingRequiredSecrets(requirements, existingSecrets)
430
431 assert.Len(t, missing, 3, "Should have 3 missing secrets")
432 assert.Equal(t, "SECRET1", missing[0].Name)
433 assert.Equal(t, "SECRET2", missing[1].Name)
434 assert.Equal(t, "SECRET3", missing[2].Name)
435 })
436
437 t.Run("all secrets exist", func(t *testing.T) {
438 requirements := []SecretRequirement{
439 {Name: "SECRET1", Optional: false},
440 {Name: "SECRET2", Optional: false},
441 }
442 existingSecrets := map[string]struct {
443 }{
444 "SECRET1": {},
445 "SECRET2": {},
446 }
447
448 missing := getMissingRequiredSecrets(requirements, existingSecrets)
449
450 assert.Empty(t, missing, "Should have no missing secrets")
451 })
452
453 t.Run("some secrets missing", func(t *testing.T) {
454 requirements := []SecretRequirement{
455 {Name: "SECRET1", Optional: false},
456 {Name: "SECRET2", Optional: false},
457 {Name: "SECRET3", Optional: false},
458 }
459 existingSecrets := map[string]struct {
460 }{
461 "SECRET1": {},
462 }
463
464 missing := getMissingRequiredSecrets(requirements, existingSecrets)
465
466 assert.Len(t, missing, 2, "Should have 2 missing secrets")
467 assert.Equal(t, "SECRET2", missing[0].Name)
468 assert.Equal(t, "SECRET3", missing[1].Name)
469 })
470
471 t.Run("optional secrets are skipped", func(t *testing.T) {
472 requirements := []SecretRequirement{
473 {Name: "REQUIRED1", Optional: false},
474 {Name: "OPTIONAL1", Optional: true},
475 {Name: "REQUIRED2", Optional: false},
476 {Name: "OPTIONAL2", Optional: true},

Callers

nothing calls this directly

Calls 2

RunMethod · 0.45

Tested by

no test coverage detected