router7/integration/dns/dns_test.go
Michael Stapelberg 5a07d6696d split integration tests into multiple packages
This makes them complete more quickly (because they are run in parallel) and
invalidates only the cache for the integration test I’m working on, not for all
of them.
2018-06-24 11:46:49 +02:00

26 lines
593 B
Go

package integration_test
import (
"os"
"os/exec"
"strconv"
"strings"
"testing"
"router7/internal/dns"
)
func TestDNS(t *testing.T) {
go dns.NewServer("localhost:4453", "lan").ListenAndServe()
const port = 4453
dig := exec.Command("dig", "-p", strconv.Itoa(port), "+timeout=1", "+short", "-x", "8.8.8.8", "@127.0.0.1")
dig.Stderr = os.Stderr
out, err := dig.Output()
if err != nil {
t.Fatal(err)
}
if got, want := strings.TrimSpace(string(out)), "google-public-dns-a.google.com."; got != want {
t.Fatalf("dig -x 8.8.8.8: unexpected reply: got %q, want %q", got, want)
}
}