feat(research): one option per way to run a game, SteamCMD recommended
A draft built on a ready-made image whose files all live outside /server
went round three times and ended as WIP, although research had also
verified the game's Steam app, which SteamCMD installs straight into
/server. The build picked among the variant's images on its own.
- research reads each Steam app's OS list. When it ships a Linux server,
the SteamCMD route is the recommended option; for Windows-only servers,
images that bring Proton or Wine come first. The research prompt says
the same.
- A variant that can run on several images becomes one option per image
("... (SteamCMD)", "... (image x/y)"), so the admin picks exactly how the
server runs.
- build uses exactly the chosen option and never switches to another; if it
can't be made to work, the PR says so and another option can be picked.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
274ed68cc5
commit
f2ffed5c98
3 files changed
+202
-61
No files matched your search
@@ -39,3 +39,76 @@ func TestAppNameFromAppInfo(t *testing.T) {
|
||||
t.Errorf("got %v", m)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseAppInfoFindsLinuxServers(t *testing.T) {
|
||||
linux, ok := parseAppInfo(`"1000000"
|
||||
{
|
||||
"common"
|
||||
{
|
||||
"name" "Example Dedicated Server"
|
||||
"oslist" "windows,linux"
|
||||
}
|
||||
}`)
|
||||
if !ok || linux.name != "Example Dedicated Server" || !linux.linux {
|
||||
t.Errorf("got %+v %v", linux, ok)
|
||||
}
|
||||
// A server that only exists for Windows (needs Proton or Wine)
|
||||
windows, _ := parseAppInfo(`"common" { "name" "Example Server" "oslist" "windows" }`)
|
||||
if windows.linux {
|
||||
t.Error("windows-only app reported as linux")
|
||||
}
|
||||
}
|
||||
|
||||
func TestWithSteamCMDGoesFirstOnlyForLinuxServers(t *testing.T) {
|
||||
images := []string{"someone/example-server", "cm2network/steamcmd", "other/example"}
|
||||
got := withSteamCMD(images, true)
|
||||
if len(got) != 3 || got[0] != "cm2network/steamcmd" || got[1] != "someone/example-server" {
|
||||
t.Errorf("linux: %v", got)
|
||||
}
|
||||
got = withSteamCMD([]string{"someone/proton-example"}, false)
|
||||
if len(got) != 2 || got[1] != "cm2network/steamcmd" {
|
||||
t.Errorf("windows-only: %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRecommendPrefersTheSteamCMDVariant(t *testing.T) {
|
||||
v := []variant{
|
||||
{ID: "image", Recommended: true, Images: []string{"someone/example-server"}},
|
||||
{ID: "steam", Images: []string{"cm2network/steamcmd", "someone/example-server"}},
|
||||
{ID: "broken", Recommended: true},
|
||||
}
|
||||
recommend(v)
|
||||
if v[0].Recommended || !v[1].Recommended || v[2].Recommended {
|
||||
t.Errorf("got %+v", v)
|
||||
}
|
||||
// Without a SteamCMD variant, the model's runnable choice stands
|
||||
v = []variant{{ID: "a", Images: []string{"x/a"}}, {ID: "b", Recommended: true, Images: []string{"x/b"}}}
|
||||
recommend(v)
|
||||
if v[0].Recommended || !v[1].Recommended {
|
||||
t.Errorf("got %+v", v)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOneOptionPerImageThenSteamCMDRecommended(t *testing.T) {
|
||||
v := oneOptionPerImage([]variant{{
|
||||
ID: "dedicated", Title: "Example Dedicated Server", Recommended: true, SteamAppID: "1000000",
|
||||
Images: withSteamCMD([]string{"someone/example-server"}, true),
|
||||
Verified: []string{"image someone/example-server exists", "Steam app 1000000 is \"Example Dedicated Server\""},
|
||||
}})
|
||||
recommend(v)
|
||||
if len(v) != 2 {
|
||||
t.Fatalf("want one option per image, got %+v", v)
|
||||
}
|
||||
steam, image := v[0], v[1]
|
||||
if steam.Title != "Example Dedicated Server (SteamCMD)" || !steam.Recommended || steam.SteamAppID != "1000000" || len(steam.Images) != 1 {
|
||||
t.Errorf("SteamCMD option: %+v", steam)
|
||||
}
|
||||
if image.Title != "Example Dedicated Server (image someone/example-server)" || image.Recommended || image.SteamAppID != "" {
|
||||
t.Errorf("image option: %+v", image)
|
||||
}
|
||||
for _, line := range steam.Verified {
|
||||
if line == "image someone/example-server exists" {
|
||||
t.Error("SteamCMD option lists the other option's image check")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user