Review comments from PR review

Signed-off-by: Evans Mungai <mbuevans@gmail.com>
pull/31601/head
Evans Mungai 4 weeks ago
parent 10c4c253a2
commit 12bee37367
No known key found for this signature in database
GPG Key ID: BBEB812143DD14E1

@ -22,6 +22,7 @@ import (
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"helm.sh/helm/v4/internal/test/ensure"
@ -487,39 +488,32 @@ func TestDownloadToCache(t *testing.T) {
}
func TestStripDigestAlgorithm(t *testing.T) {
tests := []struct {
name string
tests := map[string]struct {
input string
expected string
}{
{
name: "sha256 prefixed digest",
"sha256 prefixed digest": {
input: "sha256:aef46c66a7f2d5a12a7e3f54a64790daf5c9a9e66af3f46955efdaa6c900341d",
expected: "aef46c66a7f2d5a12a7e3f54a64790daf5c9a9e66af3f46955efdaa6c900341d",
},
{
name: "sha512 prefixed digest",
"sha512 prefixed digest": {
input: "sha512:abcdef1234567890",
expected: "abcdef1234567890",
},
{
name: "plain hex digest without prefix",
"plain hex digest without prefix": {
input: "aef46c66a7f2d5a12a7e3f54a64790daf5c9a9e66af3f46955efdaa6c900341d",
expected: "aef46c66a7f2d5a12a7e3f54a64790daf5c9a9e66af3f46955efdaa6c900341d",
},
{
name: "empty string",
"empty string": {
input: "",
expected: "",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
result := stripDigestAlgorithm(tt.input)
if result != tt.expected {
t.Errorf("stripDigestAlgorithm(%q) = %q, want %q", tt.input, result, tt.expected)
}
assert.Equalf(t, tt.expected, result, "stripDigestAlgorithm(%q) = %q, want %q", tt.input, result, tt.expected)
})
}
}

Loading…
Cancel
Save