fix legacy SCUM RCON runtime profile resolution

This commit is contained in:
npc0-hue
2026-08-24 11:27:08 +08:00
parent b69939a5ce
commit dc9b0eaf2a
4 changed files with 64 additions and 8 deletions
+23
View File
@@ -41,6 +41,29 @@ func TestRegisteredRuntimeProfilesSurviveFileStoreReload(t *testing.T) {
}
}
func TestLegacyLocalRuntimeBindingCanonicalizesToUnambiguousLocalProcessProfile(t *testing.T) {
plugin := domain.GamePlugin{RuntimeProfiles: domain.GamePluginRuntimeProfiles{
LifecycleProfiles: []domain.RuntimeLifecycleProfile{{Key: "run-local", Mode: "local-process"}},
}}
binding, err := normalizeRuntimeBinding(plugin, domain.RuntimeBinding{ID: "binding-legacy", ServerInstanceID: "server-legacy", PluginID: "plugin-legacy", PluginVersion: "1.0.0", ProfileKey: "local", Bindings: map[string]string{}, CreatedAt: fixedTime, UpdatedAt: fixedTime})
if err != nil {
t.Fatalf("normalize legacy runtime binding: %v", err)
}
if binding.ProfileKey != "run-local" || binding.Mode != "local-process" {
t.Fatalf("expected canonical local-process profile, got %+v", binding)
}
}
func TestLegacyLocalRuntimeBindingDoesNotGuessAmbiguousProfiles(t *testing.T) {
profiles := domain.GamePluginRuntimeProfiles{LifecycleProfiles: []domain.RuntimeLifecycleProfile{
{Key: "run-local", Mode: "local-process"},
{Key: "run-local-alt", Mode: "local-process"},
}}
if _, ok := runtimeLifecycleProfile(profiles, "local"); ok {
t.Fatal("expected ambiguous legacy local profile lookup to fail")
}
}
func TestRuntimeBindingValidationAndLifecycleGating(t *testing.T) {
svc := newTestCoreService()
plugin, endpoint := createPluginAndRunEndpoint(t, svc)