Files
ctrld/internal/dnsrcode/rcode_test.go
Cuong Manh Le ccada70e31 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.
2022-12-14 23:34:24 +07:00

30 lines
505 B
Go

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))
})
}
}