Skip to content

Commit

Permalink
Resolve states of partial results recursively and now correctly (#107)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
RincewindsHat and Lorenz Kästle authored Nov 6, 2023
1 parent 1a88748 commit 6cfc38c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion result/overall.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ func (s *PartialResult) GetStatus() int {
states := make([]int, len(s.PartialResults))

for i := range s.PartialResults {
states[i] = s.PartialResults[i].state
states[i] = s.PartialResults[i].GetStatus()
}

return WorstState(states...)
Expand Down
6 changes: 3 additions & 3 deletions result/overall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,15 +323,15 @@ func TestOverall_withSubchecks_PartialResult(t *testing.T) {

overall.AddSubcheck(subcheck)

res := `states: ok=1
\_ [OK] PartialResult
res := `states: critical=1
\_ [CRITICAL] PartialResult
\_ [CRITICAL] SubSubcheck
\_ [CRITICAL] SubSubSubcheck
|foo=3 bar=300% baz=23B
`

assert.Equal(t, res, overall.GetOutput())
assert.Equal(t, 0, overall.GetStatus())
assert.Equal(t, check.Critical, overall.GetStatus())
}

func TestOverall_withSubchecks_PartialResultStatus(t *testing.T) {
Expand Down

0 comments on commit 6cfc38c

Please sign in to comment.