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:
-rw-r--r--domain_config_test.go6
-rw-r--r--domain_test.go4
-rw-r--r--domains_test.go8
-rw-r--r--helper_test.go21
4 files changed, 35 insertions, 4 deletions
diff --git a/domain_config_test.go b/domain_config_test.go
index d38accf8..507eb3a9 100644
--- a/domain_config_test.go
+++ b/domain_config_test.go
@@ -9,7 +9,7 @@ import (
"path/filepath"
)
-const configFile = "shared/pages/test-group/test-project/config.json"
+const configFile = "test-group/test-project/config.json"
const invalidConfig = `{"Domains":{}}`
const validConfig = `{"Domains":[{"Domain":"test"}]}`
@@ -39,12 +39,14 @@ func TestDomainConfigValidness(t *testing.T) {
}
func TestDomainConfigRead(t *testing.T) {
+ setUpTests()
+
d := domainsConfig{}
err := d.Read("test-group", "test-project")
assert.Error(t, err)
os.MkdirAll(filepath.Dir(configFile), 0700)
- defer os.RemoveAll("shared/pages/test-group")
+ defer os.RemoveAll("test-group")
d = domainsConfig{}
err = d.Read("test-group", "test-project")
diff --git a/domain_test.go b/domain_test.go
index dac9b2a1..582779ea 100644
--- a/domain_test.go
+++ b/domain_test.go
@@ -6,6 +6,8 @@ import (
)
func TestGroupServeHTTP(t *testing.T) {
+ setUpTests()
+
testGroup := &domain{
Group: "group",
Project: "",
@@ -28,6 +30,8 @@ func TestGroupServeHTTP(t *testing.T) {
}
func TestDomainServeHTTP(t *testing.T) {
+ setUpTests()
+
testDomain := &domain{
Group: "group",
Project: "project2",
diff --git a/domains_test.go b/domains_test.go
index 0406617f..cf439c7e 100644
--- a/domains_test.go
+++ b/domains_test.go
@@ -10,9 +10,11 @@ import (
"time"
)
-const updateFile = "shared/pages/.update"
+const updateFile = ".update"
func TestReadProjects(t *testing.T) {
+ setUpTests()
+
*pagesDomain = "test.io"
d := make(domains)
@@ -47,10 +49,12 @@ func writeRandomTimestamp() {
}
func TestWatchDomains(t *testing.T) {
+ setUpTests()
+
update := make(chan domains)
go watchDomains(func(domains domains) {
update <- domains
- }, time.Microsecond)
+ }, time.Microsecond * 50)
defer os.Remove(updateFile)
diff --git a/helper_test.go b/helper_test.go
new file mode 100644
index 00000000..089e7403
--- /dev/null
+++ b/helper_test.go
@@ -0,0 +1,21 @@
+package main
+
+import (
+ "os"
+ "log"
+)
+
+var chdirSet = false
+
+func setUpTests() {
+ if chdirSet {
+ return
+ }
+
+ err := os.Chdir("shared/pages")
+ if err != nil {
+ log.Println("Chdir:", err)
+ } else {
+ chdirSet = true
+ }
+}