MCPcopy Create free account
hub / github.com/Facets-cloud/flow / TestLoadConstantsDefaultsAndOverride

Function TestLoadConstantsDefaultsAndOverride

internal/stats/model_test.go:30–49  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28}
29
30func 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
51func TestLoadConstantsCorrupt(t *testing.T) {
52 dir := t.TempDir()

Callers

nothing calls this directly

Calls 2

LoadConstantsFunction · 0.85
DefaultConstantsFunction · 0.85

Tested by

no test coverage detected