Debian Codegraph @

cmd/atomdns/handlers/log/setup_test.go

raw
1 package log
2
3 import (
4 "reflect"
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 *Log
14 }{
15 {`log {
16 aaa/addr
17 aaa/bloep
18 bbb/addr
19 }`, &Log{Contexts: map[string][]string{
20 "aaa": {"addr", "bloep"},
21 "bbb": {"addr"},
22 }},
23 },
24 }
25 for i, tc := range testcases {
26 log := new(Log)
27 co := dnsserver.NewTestController(tc.input)
28 err := log.Setup(co)
29 if err != nil {
30 t.Fatal(err)
31 }
32
33 if !reflect.DeepEqual(tc.exp.Contexts, log.Contexts) {
34 t.Errorf("test %d: expected %v, got %v", i, tc.exp.Contexts, log.Contexts)
35 }
36 }
37 }