Debian Codegraph @

cmd/atomdns/handlers/url/setup_test.go

raw
1 package url
2
3 import (
4 "slices"
5 "testing"
6
7 "codeberg.org/miekg/dns/cmd/atomdns/internal/dnsserver"
8 )
9
10 func TestSetup(t *testing.T) {
11 testcases := []struct {
12 input string
13 exp *Url
14 }{
15 {`url path {
16 https://example.org
17 https://example.net
18 }
19 }`, &Url{Path: "path", URLs: []string{"https://example.org", "https://example.net"}}},
20 }
21 for i, tc := range testcases {
22 url := new(Url)
23 co := dnsserver.NewTestController(tc.input)
24 err := url.Setup(co)
25 if err != nil {
26 t.Error(err)
27 continue
28 }
29
30 if slices.Compare(tc.exp.URLs, url.URLs) != 0 {
31 t.Errorf("test %d: expected %v, got %v", i, tc.exp.URLs, url.URLs)
32 }
33 }
34 }