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:
authorJaime Martinez <jmartinez@gitlab.com>2020-07-24 08:38:42 +0300
committerJaime Martinez <jmartinez@gitlab.com>2020-08-04 09:44:10 +0300
commit194bf0568619be8df50a51ed5979a34d4f697b7d (patch)
tree1692ce5f51e81ea7cf78fecb854031c7d53568ed /internal/source/domains_test.go
parent78f5156896899c1e444f6b80b2a02a4e89a30f45 (diff)
Add polling to the domains package
Fix linter
Diffstat (limited to 'internal/source/domains_test.go')
-rw-r--r--internal/source/domains_test.go38
1 files changed, 16 insertions, 22 deletions
diff --git a/internal/source/domains_test.go b/internal/source/domains_test.go
index 24008b08..da6f3877 100644
--- a/internal/source/domains_test.go
+++ b/internal/source/domains_test.go
@@ -2,6 +2,7 @@ package source
import (
"math/rand"
+ "sync"
"testing"
"time"
@@ -67,10 +68,7 @@ func TestGetDomain(t *testing.T) {
Once()
defer newSource.AssertExpectations(t)
- domains := &Domains{
- disk: disk.New(),
- gitlab: newSource,
- }
+ domains := newTestDomains(t, newSource)
domains.GetDomain(testDomain)
})
@@ -79,10 +77,7 @@ func TestGetDomain(t *testing.T) {
newSource := NewMockSource()
defer newSource.AssertExpectations(t)
- domains := &Domains{
- disk: disk.New(),
- gitlab: newSource,
- }
+ domains := newTestDomains(t, newSource)
domain, err := domains.GetDomain("domain.test.io")
@@ -94,10 +89,7 @@ func TestGetDomain(t *testing.T) {
newSource := NewMockSource()
defer newSource.AssertExpectations(t)
- domains := &Domains{
- disk: disk.New(),
- gitlab: newSource,
- }
+ domains := newTestDomains(t, newSource)
domain, err := domains.GetDomain("pages-broken-poc.gitlab.io")
@@ -124,10 +116,7 @@ func TestGetDomain(t *testing.T) {
Once()
defer newSource.AssertExpectations(t)
- domains := &Domains{
- disk: disk.New(),
- gitlab: newSource,
- }
+ domains := newTestDomains(t, newSource)
domains.GetDomain(testDomain)
})
@@ -156,8 +145,6 @@ func TestGetDomainWithIncrementalrolloutOfGitLabSource(t *testing.T) {
// Generates FNV 2643293380, 2643293380 % 100 = 80
domain80 := "test-domain-b.com"
- diskSource := disk.New()
-
gitlabSourceConfig.Domains.Rollout.Percentage = 80
type testDomain struct {
@@ -203,10 +190,7 @@ func TestGetDomainWithIncrementalrolloutOfGitLabSource(t *testing.T) {
}
defer gitlabSource.AssertExpectations(t)
- domains := &Domains{
- disk: diskSource,
- gitlab: gitlabSource,
- }
+ domains := newTestDomains(t, gitlabSource)
gitlabSourceConfig.Domains.Rollout.Stickiness = tc.stickiness
@@ -217,3 +201,13 @@ func TestGetDomainWithIncrementalrolloutOfGitLabSource(t *testing.T) {
})
}
}
+
+func newTestDomains(t *testing.T, gitlabSource *MockSource) *Domains {
+ t.Helper()
+
+ return &Domains{
+ mu: &sync.RWMutex{},
+ disk: disk.New(),
+ gitlab: gitlabSource,
+ }
+}