Files
geo/server/internal/tenant/app/desktop_task_service_test.go
T
root 9d6181260a
Desktop Client Build / Resolve Build Metadata (push) Successful in 43s
Frontend CI / Frontend (push) Successful in 3m49s
Backend CI / Backend (push) Failing after 7m10s
Desktop Client Build / Build Desktop Client (push) Successful in 23m4s
Desktop Client Build / Publish Client Artifacts to NAS (push) Successful in 28s
feat(media-supply): add media resource supply marketplace
Introduce an end-to-end media-supply feature: tenant-side resource sync
service/worker backed by a Meijiequan supplier client, ops-side management
APIs, and admin/ops web views for resources, orders, favorites and
submission. Adds a shared digitocr helper, MediaSupply config blocks for
tenant and ops, shared types, and migrations for supplier media resources,
price overrides, customer visibility and order refunds.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-29 23:17:01 +08:00

82 lines
2.2 KiB
Go

package app
import (
"regexp"
"strings"
"testing"
)
func TestDesktopTaskRecoverySelectQueryMatchesRecoveredLeaseScanOrder(t *testing.T) {
t.Parallel()
query := desktopTaskRecoverySelectQuery(desktopTaskRecoveryModeStartup)
gotColumns := recoverDesktopTaskSelectColumns(query)
wantColumns := []string{
"desktop_id",
"workspace_id",
"kind",
"status",
"active_attempt_id",
}
if len(gotColumns) != len(wantColumns) {
t.Fatalf("recover select columns = %v, want %v", gotColumns, wantColumns)
}
for index := range wantColumns {
if gotColumns[index] != wantColumns[index] {
t.Fatalf("recover select columns = %v, want %v", gotColumns, wantColumns)
}
}
}
func TestDesktopTaskRecoverySelectQueryLeaseExpiryFiltersExpiredLeases(t *testing.T) {
t.Parallel()
query := desktopTaskRecoverySelectQuery(desktopTaskRecoveryModeLeaseExpiry)
for _, fragment := range []string{
"AND lease_expires_at IS NOT NULL",
"AND lease_expires_at < NOW()",
"FOR UPDATE",
} {
if !strings.Contains(query, fragment) {
t.Fatalf("recover lease-expiry query missing %q: %s", fragment, query)
}
}
}
func TestReconcileRetryPublishesTaskAvailableForAllDesktopTaskKinds(t *testing.T) {
t.Parallel()
for _, kind := range []string{"publish", "monitor"} {
if got := reconcileDesktopTaskEventType(kind, "retry"); got != "task_available" {
t.Fatalf("reconcileDesktopTaskEventType(%q, retry) = %q, want task_available", kind, got)
}
}
}
func TestReconcileNonRetryPublishesTaskReconciled(t *testing.T) {
t.Parallel()
if got := reconcileDesktopTaskEventType("publish", "failed"); got != "task_reconciled" {
t.Fatalf("reconcileDesktopTaskEventType(publish, failed) = %q, want task_reconciled", got)
}
}
func recoverDesktopTaskSelectColumns(query string) []string {
re := regexp.MustCompile(`(?is)select\s+(.*?)\s+from\s+desktop_tasks`)
match := re.FindStringSubmatch(query)
if len(match) != 2 {
return nil
}
rawColumns := strings.Split(match[1], ",")
columns := make([]string, 0, len(rawColumns))
for _, rawColumn := range rawColumns {
column := strings.TrimSpace(rawColumn)
column = strings.Fields(column)[0]
columns = append(columns, column)
}
return columns
}