diff --git a/pkg/pusher/ocipusher_test.go b/pkg/pusher/ocipusher_test.go index 91d374a42..2e4ef837a 100644 --- a/pkg/pusher/ocipusher_test.go +++ b/pkg/pusher/ocipusher_test.go @@ -393,7 +393,7 @@ func TestOCIPusher_Push_ChartOperations(t *testing.T) { } } -func TestOCIPusher_Push_InvalidChartVersion(t *testing.T) { +func TestOCIPusher_Push_MultipleOptions(t *testing.T) { chartPath := "../../pkg/cmd/testdata/testcharts/compressedchart-0.1.0.tgz" // Skip test if chart file doesn't exist @@ -407,7 +407,7 @@ func TestOCIPusher_Push_InvalidChartVersion(t *testing.T) { } // Test that multiple options are applied correctly - err = pusher.Push(chartPath, "oci://localhost:5000/test:0.2.0", + err = pusher.Push(chartPath, "oci://localhost:5000/test", WithPlainHTTP(true), WithInsecureSkipTLSVerify(true), ) @@ -417,12 +417,17 @@ func TestOCIPusher_Push_InvalidChartVersion(t *testing.T) { t.Fatal("Expected error when pushing without a valid registry") } - if !strings.Contains(err.Error(), "does not match provided chart version") { - t.Error("Expected error to mention tag mismatch") + // Verify options were applied + op := pusher.(*OCIPusher) + if !op.opts.plainHTTP { + t.Error("Expected plainHTTP option to be applied") + } + if !op.opts.insecureSkipTLSVerify { + t.Error("Expected insecureSkipTLSVerify option to be applied") } } -func TestOCIPusher_Push_MultipleOptions(t *testing.T) { +func TestOCIPusher_Push_InvalidChartVersion(t *testing.T) { chartPath := "../../pkg/cmd/testdata/testcharts/compressedchart-0.1.0.tgz" // Skip test if chart file doesn't exist @@ -435,24 +440,13 @@ func TestOCIPusher_Push_MultipleOptions(t *testing.T) { t.Fatal(err) } - // Test that multiple options are applied correctly - err = pusher.Push(chartPath, "oci://localhost:5000/test", - WithPlainHTTP(true), - WithInsecureSkipTLSVerify(true), - ) + err = pusher.Push(chartPath, "oci://localhost:5000/test:0.2.0") - // We expect an error since we're not actually pushing to a registry if err == nil { t.Fatal("Expected error when pushing without a valid registry") } - - // Verify options were applied - op := pusher.(*OCIPusher) - if !op.opts.plainHTTP { - t.Error("Expected plainHTTP option to be applied") - } - if !op.opts.insecureSkipTLSVerify { - t.Error("Expected insecureSkipTLSVerify option to be applied") + if !strings.Contains(err.Error(), "does not match provided chart version") { + t.Error("Expected error to mention tag mismatch") } } @@ -464,13 +458,13 @@ func TestOCIPusher_Push_ExpectedVersionMismatch(t *testing.T) { t.Skipf("Test chart %s not found, skipping test", chartPath) } - p, err := NewOCIPusher() + pusher, err := NewOCIPusher() if err != nil { t.Fatal(err) } // Provide an expected version that does not match the chart's version - err = p.Push(chartPath, "oci://localhost:5000/test", + err = pusher.Push(chartPath, "oci://localhost:5000/test", WithExpectedVersion("0.2.0"), )