From 97835b4cfd3277f9d0b057336dc65ac2bccdd1db Mon Sep 17 00:00:00 2001 From: Mebus Date: Mon, 22 Jan 2018 16:42:54 +0100 Subject: [PATCH] added test for private repos --- cmd/rest-server/main_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/cmd/rest-server/main_test.go b/cmd/rest-server/main_test.go index b2a71e1..44b06a2 100644 --- a/cmd/rest-server/main_test.go +++ b/cmd/rest-server/main_test.go @@ -71,3 +71,24 @@ func TestTLSSettings(t *testing.T) { }) } } + +func TestIsUserPath(t *testing.T) { + var tests = []struct { + username string + path string + result bool + }{ + {"foo", "/", false}, + {"foo", "/foo", true}, + {"foo", "/foo/", true}, + {"foo", "/foo/bar", true}, + {"foo", "/foobar", false}, + } + + for _, test := range tests { + result := isUserPath(test.username, test.path) + if result != test.result { + t.Errorf("isUserPath(%q, %q) was incorrect, got: %v, want: %v.", test.username, test.path, result, test.result) + } + } +}