mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-09-19 12:06:40 +08:00
refactor(config): 统一共享配置模板来源
This commit is contained in:
@@ -27,12 +27,31 @@ func TestLoadConfigFromBinaryDirFirstLaunchCreatesExampleOnly(t *testing.T) {
|
||||
if _, err := os.Stat(filepath.Join(dir, ConfigExampleName)); err != nil {
|
||||
t.Fatalf("config.toml.example was not created: %v", err)
|
||||
}
|
||||
examplePath := filepath.Join(dir, ConfigExampleName)
|
||||
example, err := os.ReadFile(examplePath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if string(example) != ConfigTOMLTemplate {
|
||||
t.Fatal("first-launch example differs from the canonical runtime template")
|
||||
}
|
||||
if _, err := os.Stat(filepath.Join(dir, ".env")); !os.IsNotExist(err) {
|
||||
t.Fatalf("unexpected .env after first launch, err=%v", err)
|
||||
}
|
||||
if cfg.Listen != DefaultListen || cfg.RPCTimeout != 30*time.Second {
|
||||
t.Fatalf("first launch changed defaults: %+v", cfg)
|
||||
}
|
||||
|
||||
if err := LoadConfigFromBinaryDir(dir, &cfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
unchanged, err := os.ReadFile(examplePath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if string(unchanged) != string(example) {
|
||||
t.Fatal("existing config.toml.example was modified")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckedInBatAPIConfigExampleMatchesRuntimeTemplate(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user