diff options
Diffstat (limited to 'plugin/pkg/fall/fall_test.go')
-rw-r--r-- | plugin/pkg/fall/fall_test.go | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/plugin/pkg/fall/fall_test.go b/plugin/pkg/fall/fall_test.go index 4cc043a38..9988578f6 100644 --- a/plugin/pkg/fall/fall_test.go +++ b/plugin/pkg/fall/fall_test.go @@ -2,41 +2,58 @@ package fall import "testing" -func TestIsNil(t *testing.T) { - var f *F - if !f.IsNil() { - t.Errorf("F should be nil") +func TestEqual(t *testing.T) { + var z F + f := F{Zones: []string{"example.com."}} + g := F{Zones: []string{"example.net."}} + h := F{Zones: []string{"example.com."}} + + if !f.Equal(h) { + t.Errorf("%v should equal %v", f, h) + } + + if z.Equal(f) { + t.Errorf("%v should not be equal to %v", z, f) + } + + if f.Equal(g) { + t.Errorf("%v should not be equal to %v", f, g) } } -func TestIsZero(t *testing.T) { - f := New() - if !f.IsZero() { +func TestZero(t *testing.T) { + var f F + if !f.Equal(Zero()) { t.Errorf("F should be zero") } } -func TestFallThroughExample(t *testing.T) { - if !Example.Through("example.org.") { - t.Errorf("example.org. should fall through") +func TestSetZonesFromArgs(t *testing.T) { + var f F + f.SetZonesFromArgs([]string{}) + if !f.Equal(Root()) { + t.Errorf("F should have the root zone") } - if Example.Through("example.net.") { - t.Errorf("example.net. should not fall through") + + f.SetZonesFromArgs([]string{"example.com", "example.net."}) + expected := F{Zones: []string{"example.com.", "example.net."}} + if !f.Equal(expected) { + t.Errorf("F should be %v but is %v", expected, f) } } func TestFallthrough(t *testing.T) { - var fall *F + var fall F if fall.Through("foo.com.") { - t.Errorf("Expected false, got true for nil fallthrough") + t.Errorf("Expected false, got true for zero fallthrough") } - fall = New() + fall.SetZonesFromArgs([]string{}) if !fall.Through("foo.net.") { t.Errorf("Expected true, got false for all zone fallthrough") } - fall.SetZones([]string{"foo.com", "bar.com"}) + fall.SetZonesFromArgs([]string{"foo.com", "bar.com"}) if fall.Through("foo.net.") { t.Errorf("Expected false, got true for non-matching fallthrough zone") |