Files
podinfo/pkg/api/status_test.go
2018-08-20 11:25:15 +03:00

27 lines
549 B
Go

package api
import (
"net/http"
"net/http/httptest"
"testing"
)
func TestStatusHandler(t *testing.T) {
req, err := http.NewRequest("GET", "/status/404", nil)
if err != nil {
t.Fatal(err)
}
rr := httptest.NewRecorder()
srv := NewMockServer()
srv.router.HandleFunc("/status/{code}", srv.statusHandler)
srv.router.ServeHTTP(rr, req)
// Check the status code is what we expect.
if status := rr.Code; status != http.StatusNotFound {
t.Errorf("handler returned wrong status code: got %v want %v",
status, http.StatusNotFound)
}
}