forked from ziollek/gathersrv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_test.go
41 lines (35 loc) · 1.2 KB
/
setup_test.go
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
package gathersrv
import (
"github.com/stretchr/testify/require"
"testing"
"github.com/coredns/caddy"
)
func TestShouldFailIfPassedIncorrectDomain(t *testing.T) {
c := caddy.NewTestController("dns", `gathersrv distro { }`)
err := setup(c)
require.Errorf(t, err, "Expected error if distributed domain is incorrect")
require.Contains(t, err.Error(), "Provided incorrect domain <distro>")
}
func TestShouldFailIfNoClustersSpecified(t *testing.T) {
c := caddy.NewTestController("dns", `gathersrv distro.local. { }`)
err := setup(c)
require.Errorf(t, err, "Expected error if no cluster specified")
require.Contains(t, err.Error(), "You have to provide at least one cluster definition.")
}
func TestShouldFailIfPassedIncorrectClusterDomain(t *testing.T) {
config := `gathersrv distro.local. {
cluster-a a-
}`
c := caddy.NewTestController("dns", config)
err := setup(c)
require.Errorf(t, err, "Expected error if cluster domain is incorrect")
require.Contains(t, err.Error(), "Provided incorrect domain <cluster-a>")
}
func TestShouldSetupProperly(t *testing.T) {
config := `gathersrv distro.local. {
cluster-a.local. a-
}`
c := caddy.NewTestController("dns", config)
err := setup(c)
require.NoError(t, err)
}