Skip to content

Instantly share code, notes, and snippets.

@woodsaj
Created March 23, 2017 21:30
Show Gist options
  • Save woodsaj/3718beaad9fc8c1cbdf8273dd6b182b8 to your computer and use it in GitHub Desktop.
Save woodsaj/3718beaad9fc8c1cbdf8273dd6b182b8 to your computer and use it in GitHub Desktop.
package api
import (
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
"time"
"github.com/raintank/metrictank/cluster"
)
func TestApi(t *testing.T) {
cluster.Init("default", "test", time.Now(), "http", 6060)
srv, _ := NewServer()
srv.RegisterRoutes()
ts := httptest.NewServer(srv.Macaron)
defer ts.Close()
res, err := http.Get(ts.URL + "/")
if err != nil {
t.Fatal(err)
}
resp, err := ioutil.ReadAll(res.Body)
res.Body.Close()
if err != nil {
t.Fatal(err)
}
t.Logf("%s", resp)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment