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

Function TestComputeSavings

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

Source from the content-addressed store, hash-verified

7)
8
9func TestComputeSavings(t *testing.T) {
10 c := DefaultConstants() // 20 min/run, 5 min/switch, $100/hr
11 n := Counts{AutoRuns: 3, OwnerTicks: 3, ResumeLookups: 6, RefLookups: 6, CrossLookups: 4}
12 s := ComputeSavings(c, n)
13
14 // automation: (3+3)*20/60 = 2.0 hrs ; switch: (6+6)*5/60 = 1.0 hr
15 if s.AutomationHours != 2.0 || s.ContextSwitchHours != 1.0 {
16 t.Errorf("hours = %v/%v, want 2.0/1.0", s.AutomationHours, s.ContextSwitchHours)
17 }
18 // ContextTokens is NOT set by ComputeSavings — it is assigned by BuildStats.
19 if s.ContextTokens != 0 {
20 t.Errorf("ContextTokens should be 0 after ComputeSavings (set by BuildStats), got %d", s.ContextTokens)
21 }
22 if s.AddressableCount != 10 { // cross4 + ref6
23 t.Errorf("AddressableCount = %d, want 10", s.AddressableCount)
24 }
25 if s.TotalHours != 3.0 || s.TotalDollars != 300.0 { // 3hrs * $100
26 t.Errorf("total = %v hrs / $%v, want 3.0/300", s.TotalHours, s.TotalDollars)
27 }
28}
29
30func TestLoadConstantsDefaultsAndOverride(t *testing.T) {
31 dir := t.TempDir()

Callers

nothing calls this directly

Calls 2

DefaultConstantsFunction · 0.85
ComputeSavingsFunction · 0.85

Tested by

no test coverage detected