From f234d15730463b8a2a3191910025fdee7888a884 Mon Sep 17 00:00:00 2001 From: Dominik Braun Date: Fri, 4 Dec 2020 21:23:52 +0100 Subject: [PATCH] Add tests for Entry.URLWithTrailingSlash Signed-off-by: Dominik Braun --- pkg/repo/chartrepo_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/repo/chartrepo_test.go b/pkg/repo/chartrepo_test.go index cb0a129a1..096f1b60d 100644 --- a/pkg/repo/chartrepo_test.go +++ b/pkg/repo/chartrepo_test.go @@ -400,3 +400,19 @@ func TestResolveReferenceURL(t *testing.T) { t.Errorf("%s", chartURL) } } + +func TestEntry_URLWithTrailingSlash(t *testing.T) { + urlWithTrailingSlash := "http://someserver/something/" + e := Entry{URL: urlWithTrailingSlash} + + if e.URLWithTrailingSlash() != urlWithTrailingSlash { + t.Errorf("Expected unchanged repository URL") + } + + urlWithoutTrailingSlash := strings.TrimSuffix(urlWithTrailingSlash, "/") + e = Entry{URL: urlWithoutTrailingSlash} + + if e.URLWithTrailingSlash() != urlWithTrailingSlash { + t.Errorf("Expected repository URL without trailing slash") + } +}