From a08ecdd06673d151dd6a9237b1056ca390e32424 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 18 Feb 2020 14:40:49 +0100 Subject: Add tests for gitlab source lookup path factory --- internal/source/gitlab/factory/lookup_test.go | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 internal/source/gitlab/factory/lookup_test.go diff --git a/internal/source/gitlab/factory/lookup_test.go b/internal/source/gitlab/factory/lookup_test.go new file mode 100644 index 00000000..8a606057 --- /dev/null +++ b/internal/source/gitlab/factory/lookup_test.go @@ -0,0 +1,28 @@ +package factory + +import ( + "testing" + + "github.com/stretchr/testify/require" + "gitlab.com/gitlab-org/gitlab-pages/internal/source/gitlab/api" +) + +func TestLookupPath(t *testing.T) { + t.Run("when lookup path is not a namespace project", func(t *testing.T) { + lookup := api.LookupPath{Prefix: "/something"} + + path := LookupPath(1, lookup) + + require.Equal(t, path.Prefix, "/something") + require.False(t, path.IsNamespaceProject) + }) + + t.Run("when lookup path is a namespace project", func(t *testing.T) { + lookup := api.LookupPath{Prefix: "/"} + + path := LookupPath(2, lookup) + + require.Equal(t, path.Prefix, "/") + require.True(t, path.IsNamespaceProject) + }) +} -- cgit v1.2.3