fix: sync current handlers, repair relic data and restore visible launcher consoles
This commit is contained in:
1 parent
163d4433e6
commit
74f3c4411b
46 files changed
+4599
-1402
No files matched your search
@@ -0,0 +1,58 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Addresses and ports below are deliberately different fixture values, not
|
||||
// deployment defaults. These tests must never bind sockets or start servers.
|
||||
func TestRuntimeConfigOverrides(t *testing.T) {
|
||||
t.Chdir(t.TempDir())
|
||||
for _, name := range []string{"GAC_CONFIG", "GAC_CLIENT_VERSION", "GAC_GAME_HOST", "GAC_GAME_PORT", "GAC_SDK_HOST", "GAC_SDK_PORT", "GAC_PUBLIC_GAME_HOST", "GAC_PUBLIC_SDK_URL"} {
|
||||
t.Setenv(name, "")
|
||||
if err := os.Unsetenv(name); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
base := `{"client_version":"fixture","game_host":"localhost","game_port":32101,"sdk_host":"localhost","sdk_port":32102,"public_game_host":"example.invalid","public_sdk_url":"https://example.invalid/base/"}`
|
||||
if err := os.WriteFile("server.json", []byte(base), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
local := append([]byte{0xef, 0xbb, 0xbf}, []byte(`{"game_port":32201,"launcher":{"client_path":"fixture"}}`)...)
|
||||
if err := os.WriteFile("server.local.json", local, 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cfg, err := LoadRuntimeConfig()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cfg.GamePort != 32201 || cfg.SDKPort != 32102 || cfg.PublicSDKURL != "https://example.invalid/base" {
|
||||
t.Fatalf("merge failed: %+v", cfg)
|
||||
}
|
||||
t.Setenv("GAC_GAME_PORT", "32301")
|
||||
t.Setenv("GAC_PUBLIC_GAME_HOST", "gateway.example.invalid")
|
||||
cfg, err = LoadRuntimeConfig()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cfg.GamePort != 32301 || cfg.PublicGameHost != "gateway.example.invalid" {
|
||||
t.Fatalf("environment override failed: %+v", cfg)
|
||||
}
|
||||
t.Setenv("GAC_GAME_PORT", "65536")
|
||||
if _, err := LoadRuntimeConfig(); err == nil {
|
||||
t.Fatal("out-of-range port accepted")
|
||||
}
|
||||
t.Setenv("GAC_GAME_PORT", "0")
|
||||
if _, err := LoadRuntimeConfig(); err == nil {
|
||||
t.Fatal("zero port accepted")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRuntimeConfigRequiresFile(t *testing.T) {
|
||||
t.Setenv("GAC_CONFIG", filepath.Join(t.TempDir(), "missing.json"))
|
||||
if _, err := LoadRuntimeConfig(); err == nil {
|
||||
t.Fatal("missing config silently accepted")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user