- Add tests for SanitizeEmail, SanitizeDescription, DefaultSanitizer - Add AuthMiddleware and RequireRole tests - Add admin_handlers_test.go and location_handlers_test.go - Expand application_service_test.go with more methods
33 lines
780 B
Go
33 lines
780 B
Go
package handlers_test
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/rede5/gohorsejobs/backend/internal/api/handlers"
|
|
)
|
|
|
|
func TestNewAdminHandlers(t *testing.T) {
|
|
h := handlers.NewAdminHandlers(nil, nil, nil, nil)
|
|
if h == nil {
|
|
t.Error("NewAdminHandlers should not return nil")
|
|
}
|
|
}
|
|
|
|
func TestListAccessRoles(t *testing.T) {
|
|
h := handlers.NewAdminHandlers(nil, nil, nil, nil)
|
|
|
|
req := httptest.NewRequest(http.MethodGet, "/api/v1/admin/roles", nil)
|
|
rr := httptest.NewRecorder()
|
|
|
|
h.ListAccessRoles(rr, req)
|
|
|
|
if rr.Code != http.StatusOK {
|
|
t.Errorf("Expected status 200, got %d", rr.Code)
|
|
}
|
|
|
|
if rr.Header().Get("Content-Type") != "application/json" {
|
|
t.Errorf("Expected Content-Type application/json, got %s", rr.Header().Get("Content-Type"))
|
|
}
|
|
}
|