Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2020-02-18 16:40:49 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2020-02-18 16:40:49 +0300
commita08ecdd06673d151dd6a9237b1056ca390e32424 (patch)
tree56fa74c3aff252e51b7a61d14382f4d3a68b4783
parent673ed0e161cc3d34729fd1dc1f04477f713b5f57 (diff)
Add tests for gitlab source lookup path factory
-rw-r--r--internal/source/gitlab/factory/lookup_test.go28
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)
+ })
+}