package api_test import ( "bytes" "github.com/gin-gonic/gin" "github.com/tradarr/backend/internal/api/handlers" "github.com/tradarr/backend/internal/config" "net/http" "net/http/httptest" "testing" ) func TestTicket41RejectsNullConfigurationsBeforeDatabase(t *testing.T) { const secret = "ticket41-null-fixture" router := gin.New() router.Use(gin.Recovery()) handler := handlers.New(nil, &config.Config{JWTSecret: secret}, nil, nil, nil, nil) router.PUT("/api/admin/sources/:id", handler.UpdateSource) for _, body := range []string{`null`, `{"enabled":true,"feed_urls":null}`} { r := httptest.NewRequest(http.MethodPut, "/api/admin/sources/fixture", bytes.NewBufferString(body)) r.Header.Set("Content-Type", "application/json") w := httptest.NewRecorder() router.ServeHTTP(w, r) if w.Code != http.StatusBadRequest { t.Error("null source configuration reached repository") } } }