21 lines
399 B
Go
21 lines
399 B
Go
package handler
|
|
|
|
import (
|
|
"bytes"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestProfileHandler_Update_InvalidBody(t *testing.T) {
|
|
req := httptest.NewRequest("PUT", "/profile", bytes.NewBufferString("not json"))
|
|
rr := httptest.NewRecorder()
|
|
|
|
h := &ProfileHandler{userRepo: nil}
|
|
h.Update(rr, req)
|
|
|
|
if rr.Code != http.StatusBadRequest {
|
|
t.Errorf("expected 400, got %d", rr.Code)
|
|
}
|
|
}
|