File size: 600 Bytes
6a7089a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | package config
import (
"os"
"path/filepath"
"testing"
)
func TestLoad_EngineFromConfig(t *testing.T) {
t.Setenv("PINCHTAB_CONFIG", filepath.Join(t.TempDir(), "config.json"))
cfg := Load()
if cfg.Engine != "chrome" {
t.Fatalf("default engine = %q, want chrome", cfg.Engine)
}
configPath := filepath.Join(t.TempDir(), "config.json")
if err := os.WriteFile(configPath, []byte(`{"server":{"engine":"lite"}}`), 0600); err != nil {
t.Fatal(err)
}
t.Setenv("PINCHTAB_CONFIG", configPath)
cfg = Load()
if cfg.Engine != "lite" {
t.Fatalf("file engine = %q, want lite", cfg.Engine)
}
}
|