diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2020-02-18 16:40:49 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2020-02-18 16:40:49 +0300 |
commit | a08ecdd06673d151dd6a9237b1056ca390e32424 (patch) | |
tree | 56fa74c3aff252e51b7a61d14382f4d3a68b4783 /internal | |
parent | 673ed0e161cc3d34729fd1dc1f04477f713b5f57 (diff) |
Add tests for gitlab source lookup path factory
Diffstat (limited to 'internal')
-rw-r--r-- | internal/source/gitlab/factory/lookup_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
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) + }) +} |