-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathqueries_health_test.go
More file actions
97 lines (88 loc) · 2.69 KB
/
Copy pathqueries_health_test.go
File metadata and controls
97 lines (88 loc) · 2.69 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package graph
import "testing"
func TestComputeHealthSummary_AllGood(t *testing.T) {
signals := &HealthSignals{
Tests: &HealthSignal{Status: "PASS"},
ATC: &HealthSignal{Status: "CLEAN"},
Boundaries: &HealthSignal{Status: "CLEAN"},
Staleness: &HealthSignal{Status: "ACTIVE"},
}
s := ComputeHealthSummary(signals)
if s.Status != "GOOD" {
t.Errorf("Status: got %q, want GOOD", s.Status)
}
}
func TestComputeHealthSummary_TestsFail(t *testing.T) {
signals := &HealthSignals{
Tests: &HealthSignal{Status: "FAIL"},
ATC: &HealthSignal{Status: "CLEAN"},
Boundaries: &HealthSignal{Status: "CLEAN"},
}
s := ComputeHealthSummary(signals)
if s.Status != "BAD" {
t.Errorf("Status: got %q, want BAD", s.Status)
}
}
func TestComputeHealthSummary_BoundaryViolations(t *testing.T) {
signals := &HealthSignals{
Tests: &HealthSignal{Status: "PASS"},
Boundaries: &HealthSignal{Status: "VIOLATIONS"},
}
s := ComputeHealthSummary(signals)
if s.Status != "WARN" {
t.Errorf("Status: got %q, want WARN", s.Status)
}
}
func TestComputeHealthSummary_ATCFindings(t *testing.T) {
signals := &HealthSignals{
ATC: &HealthSignal{Status: "FINDINGS"},
}
s := ComputeHealthSummary(signals)
if s.Status != "WARN" {
t.Errorf("Status: got %q, want WARN", s.Status)
}
}
func TestComputeHealthSummary_MultipleWarnings(t *testing.T) {
signals := &HealthSignals{
Tests: &HealthSignal{Status: "PASS"},
ATC: &HealthSignal{Status: "FINDINGS"},
Boundaries: &HealthSignal{Status: "VIOLATIONS"},
Staleness: &HealthSignal{Status: "STALE"},
}
s := ComputeHealthSummary(signals)
if s.Status != "WARN" {
t.Errorf("Status: got %q, want WARN", s.Status)
}
// Headline should mention all warnings
if s.Headline == "" {
t.Error("Headline should not be empty")
}
}
func TestComputeHealthSummary_NoSignals(t *testing.T) {
signals := &HealthSignals{}
s := ComputeHealthSummary(signals)
if s.Status != "GOOD" {
t.Errorf("Status: got %q, want GOOD (missing data is not failure)", s.Status)
}
}
func TestComputeHealthSummary_TestsNone(t *testing.T) {
signals := &HealthSignals{
Tests: &HealthSignal{Status: "NONE"},
ATC: &HealthSignal{Status: "CLEAN"},
}
s := ComputeHealthSummary(signals)
if s.Status != "GOOD" {
t.Errorf("Status: got %q, want GOOD (no tests = not failure)", s.Status)
}
}
func TestComputeHealthSummary_TestFailOverridesWarn(t *testing.T) {
signals := &HealthSignals{
Tests: &HealthSignal{Status: "FAIL"},
ATC: &HealthSignal{Status: "FINDINGS"},
Boundaries: &HealthSignal{Status: "VIOLATIONS"},
}
s := ComputeHealthSummary(signals)
if s.Status != "BAD" {
t.Errorf("Status: got %q, want BAD (test fail overrides warn)", s.Status)
}
}