Total rebrand across all Go API source files: - Go module path: casera-api -> honeydue-api - All imports updated (130+ files) - Docker: containers, images, networks renamed - Email templates: support email, noreply, icon URL - Domains: casera.app/mycrib.treytartt.com -> honeyDue.treytartt.com - Bundle IDs: com.tt.casera -> com.tt.honeyDue - IAP product IDs updated - Landing page, admin panel, config defaults - Seeds, CI workflows, Makefile, docs - Database table names preserved (no migration needed) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/treytartt/honeydue-api/internal/i18n"
|
|
"github.com/treytartt/honeydue-api/internal/testutil"
|
|
)
|
|
|
|
func init() {
|
|
// Initialize i18n so the custom error handler can localize error messages.
|
|
// Other handler tests get this from testutil.SetupTestDB, but these tests
|
|
// don't need a database.
|
|
i18n.Init()
|
|
}
|
|
|
|
func TestDeleteFile_MissingURL_Returns400(t *testing.T) {
|
|
// Use a test storage service — DeleteFile won't reach storage since validation fails first
|
|
storageSvc := newTestStorageService("/var/uploads")
|
|
handler := NewUploadHandler(storageSvc)
|
|
|
|
e := testutil.SetupTestRouter()
|
|
|
|
// Register route
|
|
e.DELETE("/api/uploads/", handler.DeleteFile)
|
|
|
|
// Send request with empty JSON body (url field missing)
|
|
w := testutil.MakeRequest(e, http.MethodDelete, "/api/uploads/", map[string]string{}, "test-token")
|
|
testutil.AssertStatusCode(t, w, http.StatusBadRequest)
|
|
}
|
|
|
|
func TestDeleteFile_EmptyURL_Returns400(t *testing.T) {
|
|
storageSvc := newTestStorageService("/var/uploads")
|
|
handler := NewUploadHandler(storageSvc)
|
|
|
|
e := testutil.SetupTestRouter()
|
|
e.DELETE("/api/uploads/", handler.DeleteFile)
|
|
|
|
// Send request with empty url field
|
|
w := testutil.MakeRequest(e, http.MethodDelete, "/api/uploads/", map[string]string{"url": ""}, "test-token")
|
|
testutil.AssertStatusCode(t, w, http.StatusBadRequest)
|
|
}
|