write tests for UploadTo func errors

Signed-off-by: James Sheppard <jgsheppa@protonmail.com>
pull/12063/head
James Sheppard 2 years ago
parent 966a4a5d7f
commit f2935711a9

@ -0,0 +1,30 @@
package uploader
import (
"fmt"
"testing"
"helm.sh/helm/v3/pkg/registry"
)
func TestUploadTo_InvalidFormatError(t *testing.T) {
c := ChartUploader{}
remote := "0.google.com:443/abc"
got := c.UploadTo("", remote).Error()
want := fmt.Errorf("invalid chart URL format: %s", remote).Error()
if got != want {
t.Errorf("expected error to be equal to %v, got %v", want, got)
}
}
func TestUploadTo_SchemaPrefixMissingError(t *testing.T) {
c := ChartUploader{}
remote := "www.github.com/helm/helm"
got := c.UploadTo("", remote).Error()
want := fmt.Errorf("scheme prefix missing from remote (e.g. \"%s://\")", registry.OCIScheme).Error()
if got != want {
t.Errorf("expected error to be equal to %v, got %v", want, got)
}
}
Loading…
Cancel
Save