| 1 |
package sign |
| 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 |
exp *Sign |
| 13 |
}{ |
| 14 |
{`sign db.example.org { |
| 15 |
key testdata/Kmiek.nl.+013+59725 |
| 16 |
}`, &Sign{Path: "db.example.org", Directory: "."}}, |
| 17 |
{`sign db.example.org { |
| 18 |
key testdata/Kmiek.nl.+013+59725 |
| 19 |
directory /tmp |
| 20 |
}`, &Sign{Path: "db.example.org", Directory: "/tmp"}}, |
| 21 |
} |
| 22 |
|
| 23 |
for i, tc := range testcases { |
| 24 |
sign := new(Sign) |
| 25 |
co := dnsserver.NewTestController(tc.input) |
| 26 |
err := sign.Setup(co) |
| 27 |
if err != nil { |
| 28 |
t.Fatal(err) |
| 29 |
} |
| 30 |
|
| 31 |
if tc.exp.Path != sign.Path { |
| 32 |
t.Errorf("test %d: expected %s, got %s", i, tc.exp.Path, sign.Path) |
| 33 |
} |
| 34 |
if tc.exp.Directory != sign.Directory { |
| 35 |
t.Errorf("test %d: expected %s, got %s", i, tc.exp.Directory, sign.Directory) |
| 36 |
} |
| 37 |
} |
| 38 |
} |