aboutsummaryrefslogtreecommitdiff
path: root/plugin/pkg/fall/fall_test.go
blob: 4cc043a387b0458bfcca36fadb95c2190afd7460 (plain) (blame)
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
package fall

import "testing"

func TestIsNil(t *testing.T) {
	var f *F
	if !f.IsNil() {
		t.Errorf("F should be nil")
	}
}

func TestIsZero(t *testing.T) {
	f := New()
	if !f.IsZero() {
		t.Errorf("F should be zero")
	}
}

func TestFallThroughExample(t *testing.T) {
	if !Example.Through("example.org.") {
		t.Errorf("example.org. should fall through")
	}
	if Example.Through("example.net.") {
		t.Errorf("example.net. should not fall through")
	}
}

func TestFallthrough(t *testing.T) {
	var fall *F
	if fall.Through("foo.com.") {
		t.Errorf("Expected false, got true for nil fallthrough")
	}

	fall = New()
	if !fall.Through("foo.net.") {
		t.Errorf("Expected true, got false for all zone fallthrough")
	}

	fall.SetZones([]string{"foo.com", "bar.com"})

	if fall.Through("foo.net.") {
		t.Errorf("Expected false, got true for non-matching fallthrough zone")
	}

	if !fall.Through("bar.com.") {
		t.Errorf("Expected true, got false for matching fallthrough zone")
	}
}