internal/controld: add support for parsing client id from raw UID

This commit is contained in:
Cuong Manh Le
2023-08-09 23:54:44 +07:00
committed by Cuong Manh Le
parent 19bc44a7f3
commit 72d2f4e7e3
3 changed files with 67 additions and 19 deletions
+34
View File
@@ -0,0 +1,34 @@
//go:build controld
package controld
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestFetchResolverConfig(t *testing.T) {
tests := []struct {
name string
uid string
dev bool
wantErr bool
}{
{"valid com", "p2", false, false},
{"valid dev", "p2", true, false},
{"invalid uid", "abcd1234", false, true},
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
got, err := FetchResolverConfig(tc.uid, "dev-test", tc.dev)
require.False(t, (err != nil) != tc.wantErr, err)
if !tc.wantErr {
assert.NotEmpty(t, got.DOH)
}
})
}
}