From 06dafa88f8c67e37acd0be1eb35a5c52171efbaa Mon Sep 17 00:00:00 2001 From: liangxu Date: Sun, 12 Jul 2026 14:17:36 +0800 Subject: [PATCH] test(tenant): cover desktop task platform id dedup and target count Assert uniqueMonitorDesktopTaskPlatformIDs trims and collapses duplicate account specs, and tighten the healthier-candidate case with a target length check. Apply gofmt alignment fixes. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../app/monitoring_phase2_desktop_tasks_test.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/server/internal/tenant/app/monitoring_phase2_desktop_tasks_test.go b/server/internal/tenant/app/monitoring_phase2_desktop_tasks_test.go index dd395cb..079915a 100644 --- a/server/internal/tenant/app/monitoring_phase2_desktop_tasks_test.go +++ b/server/internal/tenant/app/monitoring_phase2_desktop_tasks_test.go @@ -121,12 +121,24 @@ func TestSelectMonitorDesktopTaskTargetsPrefersHealthierOnlineCandidate(t *testi 0, ) + require.Len(t, targets, 1) assert.Equal(t, monitorDesktopTaskTarget{ AccountID: liveAccountID, ClientID: liveClientID, }, targets["qwen"]) } +func TestUniqueMonitorDesktopTaskPlatformIDsCollapsesDuplicateAccountSpecs(t *testing.T) { + platformIDs := uniqueMonitorDesktopTaskPlatformIDs([]monitorDesktopTaskSpec{ + {PlatformID: "doubao"}, + {PlatformID: " doubao "}, + {PlatformID: "qwen"}, + {PlatformID: ""}, + }) + + assert.Equal(t, []string{"doubao", "qwen"}, platformIDs) +} + func TestSelectMonitorDesktopTaskTargetsPrefersEarlierOnlineClientForSameAccount(t *testing.T) { accountID := mustParseDailyMonitoringUUID(t, "00000000-0000-0000-0000-000000000501") earlierClientID := mustParseDailyMonitoringUUID(t, "00000000-0000-0000-0000-000000000601") @@ -259,7 +271,7 @@ func TestSelectMonitorDesktopTaskTargetsRequireIdleSkipsAnyActiveBacklog(t *test clientID: 1, }, monitorDesktopTaskTargetOptions{ - MaxClientBacklog: 12, + MaxClientBacklog: 12, RequireIdleClient: true, }, ) @@ -291,7 +303,7 @@ func TestSelectMonitorDesktopTaskTargetsRequireIdleKeepsMultiplePlatformsOnSameI }, map[uuid.UUID]int{}, monitorDesktopTaskTargetOptions{ - MaxClientBacklog: 12, + MaxClientBacklog: 12, RequireIdleClient: true, }, )