all: implement policy failover rcodes

While at it, ensure that config is validated, and fixing a bug related
to reuse ctx between multiple upstreams resolving.
This commit is contained in:
Cuong Manh Le
2022-12-14 23:34:24 +07:00
committed by Cuong Manh Le
parent fe0faac8c4
commit ccada70e31
8 changed files with 148 additions and 23 deletions
+29
View File
@@ -0,0 +1,29 @@
package dnsrcode
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestFromString(t *testing.T) {
tests := []struct {
name string
rcode string
expectedRcode int
}{
{"valid", "NoError", 0},
{"upper", "NOERROR", 0},
{"lower", "noerror", 0},
{"mix", "nOeRrOr", 0},
{"invalid", "foo", -1},
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
assert.Equal(t, tc.expectedRcode, FromString(tc.rcode))
})
}
}