22 lines
483 B
Go
22 lines
483 B
Go
package web
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestPing(t *testing.T) {
|
|
app := newTestApplication(t)
|
|
request := httptest.NewRequest(http.MethodGet, "/ping", nil)
|
|
response := httptest.NewRecorder()
|
|
app.routes().ServeHTTP(response, request)
|
|
|
|
if response.Code != http.StatusOK {
|
|
t.Errorf("status: got %d, want %d", response.Code, http.StatusOK)
|
|
}
|
|
if body := response.Body.String(); body != "OK" {
|
|
t.Errorf("body: got %q, want %q", body, "OK")
|
|
}
|
|
}
|