| 1 |
package random |
| 2 |
|
| 3 |
import ( |
| 4 |
"testing" |
| 5 |
|
| 6 |
"codeberg.org/miekg/dns/cmd/atomdns/internal/dnsserver" |
| 7 |
) |
| 8 |
|
| 9 |
func TestSetup(t *testing.T) { |
| 10 |
testcases := []struct { |
| 11 |
input string |
| 12 |
fail bool |
| 13 |
}{ |
| 14 |
{`random`, false}, |
| 15 |
{`random random`, false}, |
| 16 |
{`random bla`, true}, |
| 17 |
} |
| 18 |
for i, tc := range testcases { |
| 19 |
random := new(Random) |
| 20 |
co := dnsserver.NewTestController(tc.input) |
| 21 |
err := random.Setup(co) |
| 22 |
|
| 23 |
if tc.fail && err == nil { |
| 24 |
t.Errorf("test %d: expected error, got nothing", i) |
| 25 |
} |
| 26 |
if !tc.fail && err != nil { |
| 27 |
t.Errorf("test %d: expected no error, got %s", i, err) |
| 28 |
} |
| 29 |
} |
| 30 |
} |