mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2025-12-10 09:12:51 +01:00
refactor: remove pocketbase (#1138)
This commit is contained in:
29
app/service/http_test.go
Normal file
29
app/service/http_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestJsonError(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
rec := httptest.NewRecorder()
|
||||
err := errors.New("test error")
|
||||
r := httptest.NewRequest(http.MethodGet, "/", nil)
|
||||
jsonError(rec, r, err)
|
||||
|
||||
resp := rec.Result()
|
||||
if resp.StatusCode != http.StatusInternalServerError {
|
||||
t.Errorf("expected status 500, got %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
if !strings.Contains(string(body), "test error") {
|
||||
t.Errorf("expected error message in body, got %s", string(body))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user