package runner import "testing" func TestAggregateScoreEmpty(t *testing.T) { r := &SuiteResult{} if got := r.AggregateScore(); got != 0 { t.Errorf("empty aggregate = %v, want 0", got) } } func TestAggregateScoreSingleBuild(t *testing.T) { r := &SuiteResult{ Builds: []*BuildRun{{Name: "release", TotalScore: 0.75}}, } if got := r.AggregateScore(); got != 0.75 { t.Errorf("single build aggregate = %v, want 0.75", got) } } func TestAggregateScoreTakesMinimum(t *testing.T) { r := &SuiteResult{ Builds: []*BuildRun{ {Name: "release", TotalScore: 1.0}, {Name: "debug", TotalScore: 0.9}, {Name: "sanitized", TotalScore: 0.95}, }, } if got := r.AggregateScore(); got != 0.9 { t.Errorf("aggregate = %v, want 0.9 (minimum)", got) } } func TestAggregateScoreIgnoresSkipped(t *testing.T) { r := &SuiteResult{ Builds: []*BuildRun{ {Name: "release", TotalScore: 1.0}, {Name: "sanitized", Skipped: true, SkipReason: "platforms=linux"}, {Name: "debug", TotalScore: 0.8}, }, } if got := r.AggregateScore(); got != 0.8 { t.Errorf("aggregate with skipped = %v, want 0.8", got) } } func TestAggregateScoreAllSkipped(t *testing.T) { r := &SuiteResult{ Builds: []*BuildRun{ {Name: "a", Skipped: true}, {Name: "b", Skipped: true}, }, } if got := r.AggregateScore(); got != 1.0 { t.Errorf("all-skipped aggregate = %v, want 1.0", got) } }