mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-07-16 13:17:19 +02:00
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:
committed by
Cuong Manh Le
parent
fe0faac8c4
commit
ccada70e31
@@ -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))
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user