MCPcopy Create free account
hub / github.com/coder/coder / Test_calculateSeverity

Function Test_calculateSeverity

coderd/healthcheck/workspaceproxy_internal_test.go:68–95  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

66}
67
68func Test_calculateSeverity(t *testing.T) {
69 t.Parallel()
70
71 for _, tt := range []struct {
72 total int
73 healthy int
74 warning int
75 expected health.Severity
76 }{
77 {0, 0, 0, health.SeverityOK},
78 {1, 1, 0, health.SeverityOK},
79 {1, 1, 1, health.SeverityWarning},
80 {1, 0, 0, health.SeverityError},
81 {2, 2, 0, health.SeverityOK},
82 {2, 1, 0, health.SeverityWarning},
83 {2, 1, 1, health.SeverityWarning},
84 {2, 0, 0, health.SeverityError},
85 {2, 0, 1, health.SeverityError},
86 } {
87 name := fmt.Sprintf("%d total, %d healthy, %d warning -> %s", tt.total, tt.healthy, tt.warning, tt.expected)
88 t.Run(name, func(t *testing.T) {
89 t.Parallel()
90
91 actual := calculateSeverity(tt.total, tt.healthy, tt.warning)
92 assert.Equal(t, tt.expected, actual)
93 })
94 }
95}

Callers

nothing calls this directly

Calls 3

calculateSeverityFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected