Skip to content

Commit 6cfc38c

Browse files
RincewindsHatLorenz Kästle
andauthored
Resolve states of partial results recursively and now correctly (#107)
This patch fixes a bug which causes PartialResults to show "wrong" states, when the state is derived from other PartialResults inside. The problem was a small piece of code which was forgotten, when the "explicit state" logic was introduced. Co-authored-by: Lorenz Kästle <lorenz.kaestle@netways.de>
1 parent 1a88748 commit 6cfc38c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

result/overall.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ func (s *PartialResult) GetStatus() int {
324324
states := make([]int, len(s.PartialResults))
325325

326326
for i := range s.PartialResults {
327-
states[i] = s.PartialResults[i].state
327+
states[i] = s.PartialResults[i].GetStatus()
328328
}
329329

330330
return WorstState(states...)

result/overall_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,15 @@ func TestOverall_withSubchecks_PartialResult(t *testing.T) {
323323

324324
overall.AddSubcheck(subcheck)
325325

326-
res := `states: ok=1
327-
\_ [OK] PartialResult
326+
res := `states: critical=1
327+
\_ [CRITICAL] PartialResult
328328
\_ [CRITICAL] SubSubcheck
329329
\_ [CRITICAL] SubSubSubcheck
330330
|foo=3 bar=300% baz=23B
331331
`
332332

333333
assert.Equal(t, res, overall.GetOutput())
334-
assert.Equal(t, 0, overall.GetStatus())
334+
assert.Equal(t, check.Critical, overall.GetStatus())
335335
}
336336

337337
func TestOverall_withSubchecks_PartialResultStatus(t *testing.T) {

0 commit comments

Comments
 (0)