Merge pull request #31297 from TerryHowe/fix-hide-notes-in-helm-test

fix: hide notes in helm test command
gjenkins/fix_helm4_release
George Jenkins 2 days ago committed by GitHub
commit 561a7da61c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -45,7 +45,6 @@ type ReleaseTesting struct {
// Used for fetching logs from test pods // Used for fetching logs from test pods
Namespace string Namespace string
Filters map[string][]string Filters map[string][]string
HideNotes bool
} }
// NewReleaseTesting creates a new ReleaseTesting object with the given configuration. // NewReleaseTesting creates a new ReleaseTesting object with the given configuration.

@ -77,7 +77,7 @@ func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command
release: rel, release: rel,
debug: settings.Debug, debug: settings.Debug,
showMetadata: false, showMetadata: false,
hideNotes: client.HideNotes, hideNotes: true,
noColor: settings.ShouldDisableColor(), noColor: settings.ShouldDisableColor(),
}); err != nil { }); err != nil {
return err return err
@ -99,7 +99,6 @@ func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command
f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)") f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)")
f.BoolVar(&outputLogs, "logs", false, "dump the logs from test pods (this runs after all tests are complete, but before any cleanup)") f.BoolVar(&outputLogs, "logs", false, "dump the logs from test pods (this runs after all tests are complete, but before any cleanup)")
f.StringSliceVar(&filter, "filter", []string{}, "specify tests by attribute (currently \"name\") using attribute=value syntax or '!attribute=value' to exclude a test (can specify multiple or separate values with commas: name=test1,name=test2)") f.StringSliceVar(&filter, "filter", []string{}, "specify tests by attribute (currently \"name\") using attribute=value syntax or '!attribute=value' to exclude a test (can specify multiple or separate values with commas: name=test1,name=test2)")
f.BoolVar(&client.HideNotes, "hide-notes", false, "if set, do not show notes in test output. Does not affect presence in chart metadata")
return cmd return cmd
} }

@ -17,7 +17,16 @@ limitations under the License.
package cmd package cmd
import ( import (
"bytes"
"io"
"strings"
"testing" "testing"
"helm.sh/helm/v4/pkg/action"
"helm.sh/helm/v4/pkg/chart/common"
chart "helm.sh/helm/v4/pkg/chart/v2"
kubefake "helm.sh/helm/v4/pkg/kube/fake"
release "helm.sh/helm/v4/pkg/release/v1"
) )
func TestReleaseTestingCompletion(t *testing.T) { func TestReleaseTestingCompletion(t *testing.T) {
@ -28,3 +37,44 @@ func TestReleaseTestingFileCompletion(t *testing.T) {
checkFileCompletion(t, "test", false) checkFileCompletion(t, "test", false)
checkFileCompletion(t, "test myrelease", false) checkFileCompletion(t, "test myrelease", false)
} }
func TestReleaseTestNotesHandling(t *testing.T) {
// Test that ensures notes behavior is correct for test command
// This is a simpler test that focuses on the core functionality
rel := &release.Release{
Name: "test-release",
Namespace: "default",
Info: &release.Info{
Status: release.StatusDeployed,
Notes: "Some important notes that should be hidden by default",
},
Chart: &chart.Chart{Metadata: &chart.Metadata{Name: "test", Version: "1.0.0"}},
}
// Set up storage
store := storageFixture()
store.Create(rel)
// Set up action configuration properly
actionConfig := &action.Configuration{
Releases: store,
KubeClient: &kubefake.FailingKubeClient{PrintingKubeClient: kubefake.PrintingKubeClient{Out: io.Discard}},
Capabilities: common.DefaultCapabilities,
}
// Test the newReleaseTestCmd function directly
var buf1 bytes.Buffer
// Test 1: Default behavior (should hide notes)
cmd1 := newReleaseTestCmd(actionConfig, &buf1)
cmd1.SetArgs([]string{"test-release"})
err1 := cmd1.Execute()
if err1 != nil {
t.Fatalf("Unexpected error for default test: %v", err1)
}
output1 := buf1.String()
if strings.Contains(output1, "NOTES:") {
t.Errorf("Expected notes to be hidden by default, but found NOTES section in output: %s", output1)
}
}

Loading…
Cancel
Save