chore: run go fix for Go 1.26 modernization
CI / Go vulnerabilities (push) Successful in 1m10s
CI / Build & Vet (push) Successful in 1m39s
CI / Frontend build (gate) (push) Successful in 1m42s
CI / Frontend QC (audit) (push) Successful in 56s
CI / Frontend QC (typecheck) (push) Successful in 1m36s
CI / Frontend QC (lint) (push) Successful in 1m51s
CI / Tests (prod) (push) Has been cancelled
CI / Tests (dev) (push) Has been cancelled
CI / Race (prod) (push) Has been cancelled
CI / Race (dev) (push) Has been cancelled

106 files: interface{}→any, strings.Split→SplitSeq, CutPrefix/Cut, strings.Builder, slices.Contains, remove redundant // +build directives, gofmt import ordering and indentation.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-07-09 17:25:23 +01:00
co-authored by Sisyphus
parent ef26bd59e9
commit 510828c924
107 changed files with 882 additions and 745 deletions
@@ -1,5 +1,4 @@
//go:build test
// +build test
package admin
@@ -9,8 +8,8 @@ import (
"time"
"crussell/clock"
"crussell/testutils"
"crussell/handlers/bookings"
"crussell/testutils"
"crussell/testutils/fixtures"
)
@@ -1,5 +1,4 @@
//go:build test
// +build test
package admin
+1 -19
View File
@@ -1,5 +1,4 @@
//go:build test
// +build test
package admin
@@ -32,9 +31,9 @@ import (
"crussell/clock"
"crussell/db"
"crussell/testutils"
"crussell/handlers/bookings"
"crussell/mw"
"crussell/testutils"
"crussell/testutils/fixtures"
"github.com/go-chi/chi/v5"
@@ -2247,7 +2246,6 @@ func TestAdminBookings_Create_WalkIn(t *testing.T) {
}
// Seed working hours so we have a valid booking window
// Try to create booking with walk-in time (30 minutes from now - less than 1h requirement)
// Regular users would be rejected, but admin should succeed
@@ -2291,7 +2289,6 @@ func TestAdminBookings_Create_WalkInWithDeposits(t *testing.T) {
}
// Seed working hours
// Set user to have outstanding deposits
_, err = tx.Exec(ctx, "UPDATE users SET deposits_required = 3 WHERE id = $1", userID)
@@ -2346,7 +2343,6 @@ func TestAdminBookings_Confirm_CompletesWithPayment_ReducesDeposits(t *testing.T
t.Fatalf("failed to create test service: %v", err)
}
// Set user to have deposits_required = 2
_, err = tx.Exec(ctx, "UPDATE users SET deposits_required = 2 WHERE id = $1", userID)
if err != nil {
@@ -2427,7 +2423,6 @@ func TestAdminBookings_Confirm_CompletesWithoutPayment_NoReduction(t *testing.T)
t.Fatalf("failed to create test service: %v", err)
}
// Set user to have deposits_required = 2
_, err = tx.Exec(ctx, "UPDATE users SET deposits_required = 2 WHERE id = $1", userID)
if err != nil {
@@ -2502,7 +2497,6 @@ func TestAdminBookings_Create_EnforceDepositsFalse_BypassesLimit(t *testing.T) {
t.Fatalf("failed to create test service: %v", err)
}
// Set user to have deposits_required = 3
_, err = tx.Exec(ctx, "UPDATE users SET deposits_required = 3 WHERE id = $1", userID)
if err != nil {
@@ -2564,9 +2558,7 @@ func TestAdminBookings_Create_EnforceDepositsFalse_Within24h(t *testing.T) {
t.Fatalf("failed to create test service: %v", err)
}
// Seed working hours
// Set user to have deposits_required = 3
_, err = tx.Exec(ctx, "UPDATE users SET deposits_required = 3 WHERE id = $1", userID)
@@ -2619,7 +2611,6 @@ func TestAdminBookings_Create_WalkInGuestUser(t *testing.T) {
}
// Seed working hours
// Create booking for tomorrow
tomorrow := clock.Now().Add(24 * time.Hour).Truncate(time.Second)
@@ -2661,7 +2652,6 @@ func TestAdminBookings_Create_WalkInGuestUser(t *testing.T) {
func TestGetBookingsByCreatedRange(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
@@ -2744,7 +2734,6 @@ func TestGetBookingsByCreatedRange(t *testing.T) {
func TestGetBookingsByCreatedRange_Empty(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
@@ -2824,7 +2813,6 @@ func TestGetBookingsByCreatedRange_InvalidFormat(t *testing.T) {
func TestGetBookingsByCreatedRange_OrderedByCreatedAt(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
@@ -2912,7 +2900,6 @@ func TestGetBookingsByCreatedRange_OrderedByCreatedAt(t *testing.T) {
func TestGetAdminBooking_WithDiscounts(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
userID, err := fixtures.CreateTestUser(tx)
if err != nil {
@@ -3007,7 +2994,6 @@ func createCompletedBookingWithTimeForAdmin(t *testing.T, ctx context.Context, t
func TestAdminBookings_CreateWithCustomServices(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
@@ -3084,7 +3070,6 @@ func TestAdminBookings_CreateWithCustomServices(t *testing.T) {
func TestAdminBookings_CreateWithCustomAndRegularServices(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
@@ -3208,7 +3193,6 @@ func TestAdminBookings_Create_CustomServiceValidation(t *testing.T) {
// Test 3: custom_service_ids is provided (should succeed — need working hours)
t.Run("provides custom_service_ids only", func(t *testing.T) {
customServiceID, err := fixtures.CreateTestCustomService(tx)
if err != nil {
@@ -3322,7 +3306,6 @@ func TestAdminBookings_Confirm_WithCustomOverrides(t *testing.T) {
func TestAdminBookings_CreateWithCustomServicesAndOverrides(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
@@ -3401,7 +3384,6 @@ func TestAdminBookings_CreateWithCustomServicesAndOverrides(t *testing.T) {
func TestAdminBookings_AdminReserve_WithCustomServices(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
adminID, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
+9 -7
View File
@@ -9,6 +9,7 @@ import (
"errors"
"net/http"
"strconv"
"strings"
"time"
"github.com/go-chi/chi/v5"
@@ -107,7 +108,7 @@ func GetCustomServices(w http.ResponseWriter, r *http.Request) {
}
var dataQuery string
var dataArgs []interface{}
var dataArgs []any
if q != "" {
dataQuery = `
@@ -115,7 +116,7 @@ func GetCustomServices(w http.ResponseWriter, r *http.Request) {
FROM custom_services
WHERE name ILIKE $1 OR description ILIKE $1
`
dataArgs = []interface{}{"%" + q + "%"}
dataArgs = []any{"%" + q + "%"}
dataQuery += " ORDER BY created_at DESC, id DESC LIMIT $" + strconv.Itoa(len(dataArgs)+1)
dataArgs = append(dataArgs, perPage+1)
@@ -318,7 +319,7 @@ func UpdateCustomService(w http.ResponseWriter, r *http.Request) {
return
}
updates := make(map[string]interface{})
updates := make(map[string]any)
if req.Name != nil {
updates["name"] = *req.Name
}
@@ -361,7 +362,7 @@ func UpdateCustomService(w http.ResponseWriter, r *http.Request) {
}
setClauses := make([]string, 0, len(updates))
args := make([]interface{}, 0, len(updates)+1)
args := make([]any, 0, len(updates)+1)
argIdx := 1
for field, val := range updates {
setClauses = append(setClauses, field+" = $"+strconv.Itoa(argIdx))
@@ -530,9 +531,10 @@ func joinStrings(strs []string, sep string) string {
if len(strs) == 0 {
return ""
}
result := strs[0]
var result strings.Builder
result.WriteString(strs[0])
for _, s := range strs[1:] {
result += sep + s
result.WriteString(sep + s)
}
return result
return result.String()
}
@@ -1,5 +1,4 @@
//go:build test
// +build test
package admin
@@ -24,8 +23,8 @@ import (
"strings"
"testing"
"crussell/testutils"
"crussell/mw"
"crussell/testutils"
"crussell/testutils/fixtures"
"github.com/go-chi/chi/v5"
+2 -7
View File
@@ -195,7 +195,6 @@ func GetDiscountCampaigns(w http.ResponseWriter, r *http.Request) {
return
}
w.WriteHeader(http.StatusOK)
if campaigns == nil {
@@ -384,7 +383,6 @@ func CreateDiscountCampaign(w http.ResponseWriter, r *http.Request) {
campaign.CreatedBy = &createdByDB.String
}
w.WriteHeader(http.StatusCreated)
if err := json.NewEncoder(w).Encode(campaign); err != nil {
log.Printf("Error encoding campaign: %v", err)
@@ -424,7 +422,7 @@ func UpdateDiscountCampaign(w http.ResponseWriter, r *http.Request) {
// Build dynamic update query
query := "UPDATE discount_campaigns SET updated_at = NOW()"
args := []interface{}{}
args := []any{}
argNum := 1
if req.Name != nil {
@@ -603,7 +601,6 @@ func UpdateDiscountCampaign(w http.ResponseWriter, r *http.Request) {
campaign.CreatedBy = &createdBy.String
}
w.WriteHeader(http.StatusOK)
if err := json.NewEncoder(w).Encode(campaign); err != nil {
log.Printf("Error encoding campaign: %v", err)
@@ -658,9 +655,8 @@ func DeleteDiscountCampaign(w http.ResponseWriter, r *http.Request) {
return
}
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(map[string]interface{}{
json.NewEncoder(w).Encode(map[string]any{
"message": "Campaign deleted successfully",
"id": campaignID,
})
@@ -774,7 +770,6 @@ func GetCampaignStats(w http.ResponseWriter, r *http.Request) {
BookingCount: bookingCount,
}
w.WriteHeader(http.StatusOK)
if err := json.NewEncoder(w).Encode(stats); err != nil {
log.Printf("Error encoding stats: %v", err)
@@ -1,5 +1,4 @@
//go:build test
// +build test
package admin
@@ -15,8 +14,8 @@ import (
"crussell/clock"
"crussell/db"
"crussell/testutils"
"crussell/mw"
"crussell/testutils"
"crussell/testutils/fixtures"
"github.com/go-chi/chi/v5"
@@ -24,7 +23,6 @@ import (
var testAdminID string
func makeCampaignRequest(handler http.Handler, method, path string, body interface{}, ctx context.Context, adminID string) *httptest.ResponseRecorder {
var req *http.Request
if body != nil {
+1 -1
View File
@@ -138,7 +138,7 @@ func UpdatePatchTest(w http.ResponseWriter, r *http.Request) {
}
query := "UPDATE patch_tests SET "
args := []interface{}{}
args := []any{}
i := 1
if req.Name != nil {
@@ -1,5 +1,4 @@
//go:build test
// +build test
package admin
+1 -2
View File
@@ -1,5 +1,4 @@
//go:build test
// +build test
package admin
@@ -19,9 +18,9 @@ import (
"net/http"
"testing"
"crussell/testutils"
"crussell/handlers/services"
"crussell/mw"
"crussell/testutils"
)
// TestAdminServices_Create verifies that an admin can create a new service
+7 -7
View File
@@ -8,6 +8,7 @@ import (
"net/http"
"net/url"
"strconv"
"strings"
)
type BusinessSettings struct {
@@ -67,7 +68,6 @@ func GetPublicBusinessInfo(w http.ResponseWriter, r *http.Request) {
return
}
json.NewEncoder(w).Encode(info)
}
@@ -90,7 +90,6 @@ func GetBusinessSettings(w http.ResponseWriter, r *http.Request) {
return
}
json.NewEncoder(w).Encode(s)
}
@@ -172,7 +171,7 @@ func UpdateBusinessSettings(w http.ResponseWriter, r *http.Request) {
}
setClauses := []string{}
args := []interface{}{}
args := []any{}
argIdx := 1
if req.BusinessName != nil {
@@ -231,12 +230,13 @@ func UpdateBusinessSettings(w http.ResponseWriter, r *http.Request) {
return
}
query := "UPDATE business_settings SET "
var query strings.Builder
query.WriteString("UPDATE business_settings SET ")
for i, clause := range setClauses {
if i > 0 {
query += ", "
query.WriteString(", ")
}
query += clause
query.WriteString(clause)
}
tx, err := db.Conn.Begin(r.Context())
@@ -247,7 +247,7 @@ func UpdateBusinessSettings(w http.ResponseWriter, r *http.Request) {
}
defer tx.Rollback(r.Context())
_, err = tx.Exec(r.Context(), query, args...)
_, err = tx.Exec(r.Context(), query.String(), args...)
if err != nil {
log.Printf("Failed to update business settings: %v", err)
http.Error(w, "Failed to update settings", http.StatusInternalServerError)
-1
View File
@@ -1,5 +1,4 @@
//go:build test
// +build test
package admin
-1
View File
@@ -1,5 +1,4 @@
//go:build test
// +build test
package admin
-1
View File
@@ -1,5 +1,4 @@
//go:build test
// +build test
package admin
+1 -2
View File
@@ -1,5 +1,4 @@
//go:build test
// +build test
package admin
@@ -24,10 +23,10 @@ import (
"time"
"crussell/clock"
"crussell/testutils"
"crussell/handlers/notifications"
"crussell/handlers/today"
"crussell/mw"
"crussell/testutils"
)
// TestAdminToday_CurrentNext verifies that an admin can retrieve the currently
@@ -1,5 +1,4 @@
//go:build test
// +build test
package admin
@@ -22,8 +21,8 @@ import (
"crussell/clock"
"crussell/db"
"crussell/testutils"
"crussell/handlers/bookings"
"crussell/testutils"
"crussell/testutils/fixtures"
)
@@ -80,7 +79,6 @@ func createSecondService(t *testing.T, tx db.Querier, ctx context.Context, name
func TestAdminBookings_UpdateServices_ReplaceServices(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
@@ -129,7 +127,6 @@ func TestAdminBookings_UpdateServices_ReplaceServices(t *testing.T) {
func TestAdminBookings_UpdateServices_AddService(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
@@ -175,7 +172,6 @@ func TestAdminBookings_UpdateServices_AddService(t *testing.T) {
func TestAdminBookings_UpdateServices_RemoveService(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
@@ -233,7 +229,6 @@ func TestAdminBookings_UpdateServices_RemoveService(t *testing.T) {
func TestAdminBookings_UpdateServices_WithPriceOverride(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
@@ -286,7 +281,6 @@ func TestAdminBookings_UpdateServices_WithPriceOverride(t *testing.T) {
func TestAdminBookings_UpdateServices_WithDurationOverride(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
@@ -339,7 +333,6 @@ func TestAdminBookings_UpdateServices_WithDurationOverride(t *testing.T) {
func TestAdminBookings_UpdateServices_WithBothOverrides(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
@@ -393,7 +386,6 @@ func TestAdminBookings_UpdateServices_WithBothOverrides(t *testing.T) {
func TestAdminBookings_UpdateServices_UpdateNotes(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
@@ -438,7 +430,6 @@ func TestAdminBookings_UpdateServices_UpdateNotes(t *testing.T) {
func TestAdminBookings_UpdateServices_MultipleOverrides(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
@@ -881,7 +872,6 @@ func TestAdminBookings_UpdateServices_WeCancelledBookingRejected(t *testing.T) {
func TestAdminBookings_UpdateServices_OverlapWithNextBooking(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
@@ -927,7 +917,6 @@ func TestAdminBookings_UpdateServices_OverlapWithNextBooking(t *testing.T) {
func TestAdminBookings_UpdateServices_NoOverlapSucceeds(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
@@ -972,7 +961,6 @@ func TestAdminBookings_UpdateServices_NoOverlapSucceeds(t *testing.T) {
func TestAdminBookings_UpdateServices_NoNextBookingSucceeds(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
@@ -1014,7 +1002,6 @@ func TestAdminBookings_UpdateServices_NoNextBookingSucceeds(t *testing.T) {
func TestAdminBookings_UpdateServices_ResponseShape(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
@@ -1082,7 +1069,6 @@ func TestAdminBookings_UpdateServices_ResponseShape(t *testing.T) {
func TestAdminBookings_UpdateServices_PendingBooking(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
@@ -1117,7 +1103,6 @@ func TestAdminBookings_UpdateServices_PendingBooking(t *testing.T) {
func TestAdminBookings_UpdateServices_InProgressBooking(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
@@ -1152,7 +1137,6 @@ func TestAdminBookings_UpdateServices_InProgressBooking(t *testing.T) {
func TestAdminBookings_UpdateServices_ClearNotes(t *testing.T) {
t.Parallel()
ctx, tx := testutils.SetupTestTx(t)
_, err := fixtures.CreateTestAdminUser(tx)
if err != nil {
+1 -2
View File
@@ -1,5 +1,4 @@
//go:build test
// +build test
package admin
@@ -21,9 +20,9 @@ import (
"testing"
"time"
"crussell/testutils"
"crussell/handlers/user"
"crussell/mw"
"crussell/testutils"
)
// TestAdminUsers_List verifies that an admin can list all users in the