Files
bd2/go/cmd/bd2client/prepare_test.go
T
Flechazo fe67072b7d refactor(all): share core services and streamline launcher workflows
Centralize configuration, logging, database decryption and resource metadata.
Use task dependencies for development, SDK and release builds; move source tools and game downloads to Go with ordered client preparation.
Rename the client to BD2 Launcher, add native icons, and update packaging and SDK checks.
2026-10-14 00:04:21 +08:00

42 lines
1.1 KiB
Go

package main
import (
"os"
"path/filepath"
"strings"
"testing"
)
func TestExclusivePreparationStagesCannotBeCombined(t *testing.T) {
err := prepareClient([]string{"--download", "--base"})
if err == nil || !strings.Contains(err.Error(), "separate stages") {
t.Fatalf("conflicting stages could modify the installation: %v", err)
}
}
func TestPreparePlanDoesNotReadPackageOrWriteInstallation(t *testing.T) {
for _, stage := range []string{"", "--download", "--base"} {
t.Run(stage, func(t *testing.T) {
root := t.TempDir()
packageDir := filepath.Join(root, "missing-package")
args := []string{"--plan", "--package-dir", packageDir, "--manifest", filepath.Join(root, "missing-manifest.json")}
if stage != "" {
args = append(args, stage)
}
if err := prepareClient(args); err != nil {
t.Fatal("planning required live package inputs", err)
}
entries, err := os.ReadDir(root)
if err != nil || len(entries) != 0 {
t.Fatalf("planning changed installation: %v, %v", entries, err)
}
})
}
}
func TestPrepareHelpNeedsNoInstalledGame(t *testing.T) {
if err := prepareClient([]string{"--help"}); err != nil {
t.Fatal(err)
}
}