(t *testing.T)
| 28 | } |
| 29 | |
| 30 | func TestLoadConstantsDefaultsAndOverride(t *testing.T) { |
| 31 | dir := t.TempDir() |
| 32 | // missing file → defaults |
| 33 | if got := LoadConstants(filepath.Join(dir, "nope.json")); got != DefaultConstants() { |
| 34 | t.Errorf("missing file should give defaults, got %+v", got) |
| 35 | } |
| 36 | // valid override |
| 37 | p := filepath.Join(dir, "stats.json") |
| 38 | if err := os.WriteFile(p, []byte(`{"minutes_per_unattended_run":30,"dollar_per_hour":150}`), 0o644); err != nil { |
| 39 | t.Fatal(err) |
| 40 | } |
| 41 | got := LoadConstants(p) |
| 42 | if got.MinutesPerUnattendedRun != 30 || got.DollarPerHour != 150 { |
| 43 | t.Errorf("override not applied: %+v", got) |
| 44 | } |
| 45 | // zero/missing fields fall back to defaults |
| 46 | if got.MinutesPerContextSwitch != 5 { |
| 47 | t.Errorf("unset fields should default: %+v", got) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | func TestLoadConstantsCorrupt(t *testing.T) { |
| 52 | dir := t.TempDir() |
nothing calls this directly
no test coverage detected