Fix generated Run component identity

This commit is contained in:
npc0-hue
2026-08-29 12:38:34 +08:00
parent ac14f80306
commit 34e240dc56
8 changed files with 187 additions and 16 deletions
+10 -3
View File
@@ -53,7 +53,7 @@ func TestLoadUsesEnvironment(t *testing.T) {
}
}
func TestLoadUsesBuildDefaultsWithEnvironmentOverride(t *testing.T) {
func TestLoadUsesPackagedIdentityOverEnvironment(t *testing.T) {
oldMode, oldPlatformURL, oldRunEndpointID, oldDisplayName := BuildMode, BuildPlatformURL, BuildRunEndpointID, BuildDisplayName
oldRegistrationToken, oldServerInstanceID, oldPluginID := BuildRegistrationToken, BuildServerInstanceID, BuildPluginID
oldComponentKind, oldComponentKey, oldKeyGeneration, oldVersion, oldWorkspaceSeed := BuildComponentKind, BuildComponentKey, BuildKeyGeneration, BuildVersion, BuildWorkspaceSeed
@@ -85,9 +85,16 @@ func TestLoadUsesBuildDefaultsWithEnvironmentOverride(t *testing.T) {
}
t.Setenv("RUN_PLATFORM_URL", "http://127.0.0.1:18080")
t.Setenv("RUN_ENDPOINT_ID", "stale-run")
t.Setenv("RUN_REGISTRATION_TOKEN", "stale-token")
t.Setenv("RUN_SERVER_INSTANCE_ID", "stale-server")
t.Setenv("RUN_PLUGIN_ID", "stale-plugin")
t.Setenv("RUN_COMPONENT_KIND", "client-manager")
t.Setenv("RUN_COMPONENT_KEY", "stale-profile")
t.Setenv("RUN_KEY_GENERATION", "7")
t.Setenv("RUN_VERSION", "stale-version")
cfg = Load()
if cfg.PlatformURL != "http://127.0.0.1:18080" || cfg.KeyGeneration != 7 {
t.Fatalf("expected environment override, got %+v", cfg)
if cfg.PlatformURL != "http://127.0.0.1:18080" || cfg.RunEndpointID != "run-server-1" || cfg.RegistrationToken != "compiled-run-key" || cfg.ServerInstanceID != "server-1" || cfg.PluginID != "game.scum" || cfg.ComponentKind != "run" || cfg.ComponentKey != "" || cfg.KeyGeneration != 5 || cfg.Version != "run-dist-1" {
t.Fatalf("expected packaged identity with platform URL override, got %+v", cfg)
}
}