test: enhance assertions in OCIInstaller and list tests using testify

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
pull/32289/head
Matthieu MOREL 22 hours ago
parent 26515f3bdc
commit 19cc25dc00

@ -33,6 +33,8 @@ import (
"github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"helm.sh/helm/v4/internal/test/ensure"
"helm.sh/helm/v4/pkg/cli"
@ -415,16 +417,11 @@ func TestOCIInstaller_Install_WithGetterOptions(t *testing.T) {
// Install the plugin
err = Install(installer)
if tc.wantErr {
if err == nil {
t.Error("Expected installation to fail, but it succeeded")
}
require.Error(t, err, "Expected installation to fail, but it succeeded")
} else {
if err != nil {
t.Errorf("Expected installation to succeed, got error: %v", err)
// Verify plugin was installed to the actual path
} else if !isPlugin(actualPath) {
t.Errorf("Expected plugin directory %s to contain plugin.yaml", actualPath)
}
require.NoError(t, err, "Expected installation to succeed, got error: %v", err)
// Verify plugin was installed to the actual path
assert.True(t, isPlugin(actualPath), "Expected plugin directory %s to contain plugin.yaml", actualPath)
}
})
}

@ -20,6 +20,9 @@ import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
chart "helm.sh/helm/v4/pkg/chart/v2"
"helm.sh/helm/v4/pkg/release/common"
release "helm.sh/helm/v4/pkg/release/v1"
@ -348,11 +351,8 @@ func TestReleaseListWriter(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
writer := newReleaseListWriter(tt.releases, tt.timeFormat, tt.noHeaders, tt.noColor)
if writer == nil {
t.Error("Expected writer to be non-nil")
} else if len(writer.releases) != len(tt.releases) {
t.Errorf("Expected %d releases, got %d", len(tt.releases), len(writer.releases))
}
require.NotNil(t, writer, "Expected writer to be non-nil")
assert.Len(t, writer.releases, len(tt.releases), "Expected %d releases, got %d", len(tt.releases), len(writer.releases))
})
}
}

Loading…
Cancel
Save