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

config_test.go - gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3ec51c569b95774257d8921424ea42e1d308ceae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestGitLabServerFromFlags(t *testing.T) {
	tests := []struct {
		name             string
		gitLabServer     string
		gitLabAuthServer string
		artifactsServer  string
		expected         string
	}{
		{
			name:             "When gitLabServer is set",
			gitLabServer:     "gitlabserver.com",
			gitLabAuthServer: "authserver.com",
			artifactsServer:  "https://artifactsserver.com",
			expected:         "gitlabserver.com",
		},
		{
			name:             "When auth server is set",
			gitLabServer:     "",
			gitLabAuthServer: "authserver.com",
			artifactsServer:  "https://artifactsserver.com",
			expected:         "authserver.com",
		},
		{
			name:             "When only artifacts server is set",
			gitLabServer:     "",
			gitLabAuthServer: "",
			artifactsServer:  "https://artifactsserver.com",
			expected:         "artifactsserver.com",
		},
		{
			name:             "When only artifacts server includes path",
			gitLabServer:     "",
			gitLabAuthServer: "",
			artifactsServer:  "https://artifactsserver.com:8080/api/path",
			expected:         "artifactsserver.com",
		}}

	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			gitLabServer = &test.gitLabServer
			gitLabAuthServer = &test.gitLabAuthServer
			artifactsServer = &test.artifactsServer
			assert.Equal(t, test.expected, gitlabServerFromFlags())
		})
	}
}