diff options
author | 2016-03-18 20:57:35 +0000 | |
---|---|---|
committer | 2016-03-18 20:57:35 +0000 | |
commit | 3ec0d9fe6b133a64712ae69fd712c14ad1a71f4d (patch) | |
tree | fae74c33cfed05de603785294593275f1901c861 /core/caddy_test.go | |
download | coredns-3ec0d9fe6b133a64712ae69fd712c14ad1a71f4d.tar.gz coredns-3ec0d9fe6b133a64712ae69fd712c14ad1a71f4d.tar.zst coredns-3ec0d9fe6b133a64712ae69fd712c14ad1a71f4d.zip |
First commit
Diffstat (limited to 'core/caddy_test.go')
-rw-r--r-- | core/caddy_test.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/core/caddy_test.go b/core/caddy_test.go new file mode 100644 index 000000000..1dc230a94 --- /dev/null +++ b/core/caddy_test.go @@ -0,0 +1,32 @@ +package core + +import ( + "net/http" + "testing" + "time" +) + +func TestCaddyStartStop(t *testing.T) { + caddyfile := "localhost:1984" + + for i := 0; i < 2; i++ { + err := Start(CaddyfileInput{Contents: []byte(caddyfile)}) + if err != nil { + t.Fatalf("Error starting, iteration %d: %v", i, err) + } + + client := http.Client{ + Timeout: time.Duration(2 * time.Second), + } + resp, err := client.Get("http://localhost:1984") + if err != nil { + t.Fatalf("Expected GET request to succeed (iteration %d), but it failed: %v", i, err) + } + resp.Body.Close() + + err = Stop() + if err != nil { + t.Fatalf("Error stopping, iteration %d: %v", i, err) + } + } +} |