MCPcopy
hub / github.com/helm/helm / TestUpgradeWithDryRun

Function TestUpgradeWithDryRun

pkg/cmd/upgrade_test.go:547–607  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

545}
546
547func TestUpgradeWithDryRun(t *testing.T) {
548 releaseName := "funny-bunny-labels"
549 _, _, chartPath := prepareMockReleaseWithSecret(t, releaseName)
550
551 defer resetEnv()()
552
553 store := storageFixture()
554
555 // First install a release into the store so that future --dry-run attempts
556 // have it available.
557 cmd := fmt.Sprintf("upgrade %s --install '%s'", releaseName, chartPath)
558 _, _, err := executeActionCommandC(store, cmd)
559 if err != nil {
560 t.Errorf("unexpected error, got '%v'", err)
561 }
562
563 _, err = store.Get(releaseName, 1)
564 if err != nil {
565 t.Errorf("unexpected error, got '%v'", err)
566 }
567
568 cmd = fmt.Sprintf("upgrade %s --dry-run '%s'", releaseName, chartPath)
569 _, out, err := executeActionCommandC(store, cmd)
570 if err != nil {
571 t.Errorf("unexpected error, got '%v'", err)
572 }
573
574 // No second release should be stored because this is a dry run.
575 _, err = store.Get(releaseName, 2)
576 if err == nil {
577 t.Error("expected error as there should be no new release but got none")
578 }
579
580 if !strings.Contains(out, "kind: Secret") {
581 t.Error("expected secret in output from --dry-run but found none")
582 }
583
584 // Ensure the secret is not in the output
585 cmd = fmt.Sprintf("upgrade %s --dry-run --hide-secret '%s'", releaseName, chartPath)
586 _, out, err = executeActionCommandC(store, cmd)
587 if err != nil {
588 t.Errorf("unexpected error, got '%v'", err)
589 }
590
591 // No second release should be stored because this is a dry run.
592 _, err = store.Get(releaseName, 2)
593 if err == nil {
594 t.Error("expected error as there should be no new release but got none")
595 }
596
597 if strings.Contains(out, "kind: Secret") {
598 t.Error("expected no secret in output from --dry-run --hide-secret but found one")
599 }
600
601 // Ensure there is an error when --hide-secret used without dry-run
602 cmd = fmt.Sprintf("upgrade %s --hide-secret '%s'", releaseName, chartPath)
603 _, _, err = executeActionCommandC(store, cmd)
604 if err == nil {

Callers

nothing calls this directly

Calls 7

storageFixtureFunction · 0.85
executeActionCommandCFunction · 0.85
ContainsMethod · 0.80
resetEnvFunction · 0.70
GetMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…