influxdb/admin/admin_test.go

32 lines
611 B
Go
Raw Normal View History

package admin_test
2015-02-11 07:02:25 +00:00
import (
"io/ioutil"
"net/http"
"testing"
2015-02-11 07:09:10 +00:00
"github.com/influxdb/influxdb/admin"
2015-02-11 07:02:25 +00:00
)
func Test_ServesIndexByDefault(t *testing.T) {
s := admin.NewServer(":8083")
2015-02-11 07:02:25 +00:00
go func() { s.ListenAndServe() }()
defer s.Close()
2015-02-11 07:02:25 +00:00
resp, err := http.Get("http://localhost:8083/")
if err != nil {
t.Fatalf("couldn't complete GET to / on port 8083")
}
2015-02-11 07:02:25 +00:00
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
t.Fatalf("didn't get a 200 OK response from server, got %d instead", resp.StatusCode)
}
2015-02-11 07:02:25 +00:00
_, err = ioutil.ReadAll(resp.Body)
if err != nil {
t.Fatalf("couldn't read body")
}
2015-02-11 07:02:25 +00:00
}