mirror of
https://github.com/stefanprodan/podinfo.git
synced 2026-03-02 01:50:18 +00:00
27 lines
549 B
Go
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)
|
|
}
|
|
}
|