feat(backend): update admin custom services handler

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-06-18 16:26:11 +01:00
co-authored by Sisyphus
parent 7ef3f6dcf7
commit f689202984
2 changed files with 95 additions and 105 deletions
+18 -19
View File
@@ -261,8 +261,7 @@ func TestCustomServices_List_Pagination(t *testing.T) {
handler := http.HandlerFunc(GetCustomServices)
// First page with 2 per page
w := makeAdminRequest(handler, "GET", "/api/admin/custom-services?page=1&per_page=2", nil)
w := makeAdminRequest(handler, "GET", "/api/admin/custom-services?per_page=2", nil)
if w.Code != http.StatusOK {
t.Errorf("expected status 200, got %d. body: %s", w.Code, w.Body.String())
}
@@ -272,10 +271,6 @@ func TestCustomServices_List_Pagination(t *testing.T) {
t.Fatalf("failed to parse response: %v", err)
}
if resp.Page != 1 {
t.Errorf("expected page 1, got %d", resp.Page)
}
if resp.PerPage != 2 {
t.Errorf("expected per_page 2, got %d", resp.PerPage)
}
@@ -285,7 +280,11 @@ func TestCustomServices_List_Pagination(t *testing.T) {
}
if len(resp.Services) != 2 {
t.Errorf("expected 2 services on page 1, got %d", len(resp.Services))
t.Errorf("expected 2 services on first page, got %d", len(resp.Services))
}
if resp.NextCursor == nil {
t.Fatal("expected next_cursor when items remain")
}
}
@@ -369,40 +368,40 @@ func TestCustomServices_Create_Validation(t *testing.T) {
{
name: "empty name",
req: CreateCustomServiceRequest{
Name: "",
Price: 50.00,
Name: "",
Price: 50.00,
DurationMinutes: 60,
},
},
{
name: "zero price",
req: CreateCustomServiceRequest{
Name: "Test Service",
Price: 0,
Name: "Test Service",
Price: 0,
DurationMinutes: 60,
},
},
{
name: "negative price",
req: CreateCustomServiceRequest{
Name: "Test Service",
Price: -10.00,
Name: "Test Service",
Price: -10.00,
DurationMinutes: 60,
},
},
{
name: "zero duration",
req: CreateCustomServiceRequest{
Name: "Test Service",
Price: 50.00,
Name: "Test Service",
Price: 50.00,
DurationMinutes: 0,
},
},
{
name: "excessive duration",
req: CreateCustomServiceRequest{
Name: "Test Service",
Price: 50.00,
Name: "Test Service",
Price: 50.00,
DurationMinutes: 481,
},
},
@@ -822,8 +821,8 @@ func TestCustomServices_NonAdmin(t *testing.T) {
// Test CREATE
createReq := CreateCustomServiceRequest{
Name: "Test Service",
Price: 50.00,
Name: "Test Service",
Price: 50.00,
DurationMinutes: 60,
}
w = makeUserRequest(mw.RequireAdmin(http.HandlerFunc(CreateCustomService)), "POST", "/api/admin/custom-services", createReq)