plugin/rewrite: silence these tests (#2120)

* plugin/rewrite: silence these tests

The old Unix saying: no news, is good news.

Signed-off-by: Miek Gieben <miek@miek.nl>

* Fix da tests

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben
2018-09-22 15:28:13 +01:00
committed by GitHub
parent 7b40b14e96
commit 7b078a885f

View File

@@ -2,11 +2,12 @@ package rewrite
import ( import (
"context" "context"
"reflect"
"testing"
"github.com/coredns/coredns/plugin" "github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/pkg/dnstest"
"github.com/coredns/coredns/plugin/test" "github.com/coredns/coredns/plugin/test"
"reflect"
"testing"
"github.com/miekg/dns" "github.com/miekg/dns"
) )
@@ -40,11 +41,9 @@ func TestNewTtlRule(t *testing.T) {
failed = true failed = true
} }
if !failed && !tc.expectedFail { if !failed && !tc.expectedFail {
t.Logf("Test %d: PASS, passed as expected: (%s) %s", i, tc.next, tc.args)
continue continue
} }
if failed && tc.expectedFail { if failed && tc.expectedFail {
t.Logf("Test %d: PASS, failed as expected: (%s) %s: %s", i, tc.next, tc.args, err)
continue continue
} }
t.Fatalf("Test %d: FAIL, expected fail=%t, but received fail=%t: (%s) %s, rule=%v", i, tc.expectedFail, failed, tc.next, tc.args, rule) t.Fatalf("Test %d: FAIL, expected fail=%t, but received fail=%t: (%s) %s, rule=%v", i, tc.expectedFail, failed, tc.next, tc.args, rule)
@@ -57,11 +56,9 @@ func TestNewTtlRule(t *testing.T) {
failed = true failed = true
} }
if !failed && !tc.expectedFail { if !failed && !tc.expectedFail {
t.Logf("Test %d: PASS, passed as expected: (%s) %s", i, tc.next, tc.args)
continue continue
} }
if failed && tc.expectedFail { if failed && tc.expectedFail {
t.Logf("Test %d: PASS, failed as expected: (%s) %s: %s", i, tc.next, tc.args, err)
continue continue
} }
t.Fatalf("Test %d: FAIL, expected fail=%t, but received fail=%t: (%s) %s, rule=%v", i, tc.expectedFail, failed, tc.next, tc.args, rule) t.Fatalf("Test %d: FAIL, expected fail=%t, but received fail=%t: (%s) %s, rule=%v", i, tc.expectedFail, failed, tc.next, tc.args, rule)
@@ -119,7 +116,6 @@ func doTtlTests(rules []Rule, t *testing.T) {
} }
ctx := context.TODO() ctx := context.TODO()
for i, tc := range tests { for i, tc := range tests {
failed := false
m := new(dns.Msg) m := new(dns.Msg)
m.SetQuestion(tc.from, tc.fromType) m.SetQuestion(tc.from, tc.fromType)
m.Question[0].Qclass = dns.ClassINET m.Question[0].Qclass = dns.ClassINET
@@ -134,22 +130,13 @@ func doTtlTests(rules []Rule, t *testing.T) {
resp := rec.Msg resp := rec.Msg
if len(resp.Answer) == 0 { if len(resp.Answer) == 0 {
t.Errorf("Test %d: FAIL %s (%d) Expected valid response but received %q", i, tc.from, tc.fromType, resp) t.Errorf("Test %d: FAIL %s (%d) Expected valid response but received %q", i, tc.from, tc.fromType, resp)
failed = true
continue continue
} }
for _, a := range resp.Answer { for _, a := range resp.Answer {
if a.Header().Ttl != tc.ttl { if a.Header().Ttl != tc.ttl {
t.Errorf("Test %d: FAIL %s (%d) Expected TTL to be %d but was %d", i, tc.from, tc.fromType, tc.ttl, a.Header().Ttl) t.Errorf("Test %d: FAIL %s (%d) Expected TTL to be %d but was %d", i, tc.from, tc.fromType, tc.ttl, a.Header().Ttl)
failed = true
break break
} }
} }
if !failed {
if tc.noRewrite {
t.Logf("Test %d: PASS %s (%d) worked as expected, no rewrite for ttl %d", i, tc.from, tc.fromType, tc.ttl)
} else {
t.Logf("Test %d: PASS %s (%d) worked as expected, rewrote ttl to %d", i, tc.from, tc.fromType, tc.ttl)
}
}
} }
} }