diff options
author | 2020-07-08 09:00:26 -0700 | |
---|---|---|
committer | 2020-07-08 09:00:26 -0700 | |
commit | 614d08cba29ed4904d11008e795c081c4f392b77 (patch) | |
tree | e4601abda23ec9d18e2929433c260a37928e1344 /plugin/pkg/parse/parse_test.go | |
parent | 68f1dd5ddf0451cc3a1b24a72c2965b8d896ffba (diff) | |
download | coredns-614d08cba29ed4904d11008e795c081c4f392b77.tar.gz coredns-614d08cba29ed4904d11008e795c081c4f392b77.tar.zst coredns-614d08cba29ed4904d11008e795c081c4f392b77.zip |
Revert "Implement notifies for transfer plugin (#3972)" (#3995)
This reverts commit 68f1dd5ddf0451cc3a1b24a72c2965b8d896ffba.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Diffstat (limited to 'plugin/pkg/parse/parse_test.go')
-rw-r--r-- | plugin/pkg/parse/parse_test.go | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/plugin/pkg/parse/parse_test.go b/plugin/pkg/parse/parse_test.go index b1a9f0282..a9f947a7d 100644 --- a/plugin/pkg/parse/parse_test.go +++ b/plugin/pkg/parse/parse_test.go @@ -6,41 +6,65 @@ import ( "github.com/caddyserver/caddy" ) -func TestTransferIn(t *testing.T) { +func TestTransfer(t *testing.T) { tests := []struct { inputFileRules string shouldErr bool + secondary bool + expectedTo []string expectedFrom []string }{ + // OK transfer to + { + `to 127.0.0.1`, + false, false, []string{"127.0.0.1:53"}, []string{}, + }, + // OK transfer tos + { + `to 127.0.0.1 127.0.0.2`, + false, false, []string{"127.0.0.1:53", "127.0.0.2:53"}, []string{}, + }, + // OK transfer from { `from 127.0.0.1`, - false, []string{"127.0.0.1:53"}, + false, true, []string{}, []string{"127.0.0.1:53"}, }, // OK transfer froms { `from 127.0.0.1 127.0.0.2`, - false, []string{"127.0.0.1:53", "127.0.0.2:53"}, + false, true, []string{}, []string{"127.0.0.1:53", "127.0.0.2:53"}, + }, + // OK transfer tos/froms + { + `to 127.0.0.1 127.0.0.2 + from 127.0.0.1 127.0.0.2`, + false, true, []string{"127.0.0.1:53", "127.0.0.2:53"}, []string{"127.0.0.1:53", "127.0.0.2:53"}, + }, + // Bad transfer from, secondary false + { + `from 127.0.0.1`, + true, false, []string{}, []string{}, }, // Bad transfer from garbage { `from !@#$%^&*()`, - true, []string{}, + true, true, []string{}, []string{}, }, // Bad transfer from no args { `from`, - true, []string{}, + true, false, []string{}, []string{}, }, // Bad transfer from * { `from *`, - true, []string{}, + true, true, []string{}, []string{}, }, } for i, test := range tests { c := caddy.NewTestController("dns", test.inputFileRules) - froms, err := TransferIn(c) + tos, froms, err := Transfer(c, test.secondary) if err == nil && test.shouldErr { t.Fatalf("Test %d expected errors, but got no error %+v %+v", i, err, test) @@ -48,6 +72,13 @@ func TestTransferIn(t *testing.T) { t.Fatalf("Test %d expected no errors, but got '%v'", i, err) } + if test.expectedTo != nil { + for j, got := range tos { + if got != test.expectedTo[j] { + t.Fatalf("Test %d expected %v, got %v", i, test.expectedTo[j], got) + } + } + } if test.expectedFrom != nil { for j, got := range froms { if got != test.expectedFrom[j] { |