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:
authorfeistel <6742251-feistel@users.noreply.gitlab.com>2021-08-19 09:01:17 +0300
committerfeistel <6742251-feistel@users.noreply.gitlab.com>2021-08-20 04:39:10 +0300
commit9ce45c3e795ebc956016df48008057d1b429542a (patch)
treeb46396da618d121586ae19cc430e69cf5120f58d /internal/source/domains_test.go
parent26f3b1e4426d25e43f4f044c49bb53286430c784 (diff)
test: add back domains test
this was actually a valid test, we just need to make sure the test case related to disk source are pruned and gitlab source config is being tested
Diffstat (limited to 'internal/source/domains_test.go')
-rw-r--r--internal/source/domains_test.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/internal/source/domains_test.go b/internal/source/domains_test.go
index 10923be3..c3f0d2cc 100644
--- a/internal/source/domains_test.go
+++ b/internal/source/domains_test.go
@@ -3,12 +3,66 @@ package source
import (
"context"
"testing"
+ "time"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitlab-pages/internal/config"
"gitlab.com/gitlab-org/gitlab-pages/internal/domain"
)
+func TestNewDomains(t *testing.T) {
+ validCfg := config.GitLab{
+ InternalServer: "https://gitlab.com",
+ APISecretKey: []byte("abc"),
+ ClientHTTPTimeout: time.Second,
+ JWTTokenExpiration: time.Second,
+ }
+
+ tests := []struct {
+ name string
+ config config.GitLab
+ expectedErr string
+ }{
+ {
+ name: "gitlab_source_success",
+ config: validCfg,
+ },
+ {
+ name: "gitlab_source_no_url",
+ config: func() config.GitLab {
+ cfg := validCfg
+ cfg.InternalServer = ""
+
+ return cfg
+ }(),
+ expectedErr: "GitLab API URL or API secret has not been provided",
+ },
+ {
+ name: "gitlab_source_no_secret",
+ config: func() config.GitLab {
+ cfg := validCfg
+ cfg.APISecretKey = []byte{}
+
+ return cfg
+ }(),
+ expectedErr: "GitLab API URL or API secret has not been provided",
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ domains, err := NewDomains(&tt.config)
+ if tt.expectedErr != "" {
+ require.EqualError(t, err, tt.expectedErr)
+ return
+ }
+ require.NoError(t, err)
+ require.NotNil(t, domains.gitlab)
+ })
+ }
+}
+
func TestGetDomain(t *testing.T) {
t.Run("when requesting an existing domain for gitlab source", func(t *testing.T) {
testDomain := "new-source-test.gitlab.io"