Skip to content

Commit

Permalink
re-add logs in claim file
Browse files Browse the repository at this point in the history
  • Loading branch information
edcdavid committed Dec 13, 2023
1 parent c8ed3ad commit 997c019
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
17 changes: 9 additions & 8 deletions pkg/checksdb/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ type Check struct {

Result CheckResult
CapturedOutput string
FailureReason string
Details string
SkipReason string

logger *log.Logger
logArchive *strings.Builder
Expand Down Expand Up @@ -189,7 +190,7 @@ func (check *Check) SetResult(compliantObjects, nonCompliantObjects []*testhelpe
check.LogError("Failed to get result objects string for check %s: %v", check.ID, err)
}

check.CapturedOutput = resultObjectsStr
check.Details = resultObjectsStr

// If an error/panic happened before, do not change the result.
if check.Result == CheckResultError {
Expand All @@ -198,11 +199,11 @@ func (check *Check) SetResult(compliantObjects, nonCompliantObjects []*testhelpe

if len(nonCompliantObjects) > 0 {
check.Result = CheckResultFailed
check.FailureReason = resultObjectsStr
check.SkipReason = resultObjectsStr
} else if len(compliantObjects) == 0 {
// Mark this check as skipped.
check.LogWarn("Check %s marked as skipped as both compliant and non-compliant objects lists are empty.", check.ID)
check.FailureReason = "Compliant and non-compliant objects lists are empty."
check.SkipReason = "Compliant and non-compliant objects lists are empty."
check.Result = CheckResultSkipped
}
}
Expand All @@ -216,7 +217,7 @@ func (check *Check) SetResultFailed(reason string) {
}

check.Result = CheckResultFailed
check.FailureReason = reason
check.SkipReason = reason
}

func (check *Check) SetResultSkipped(reason string) {
Expand All @@ -228,7 +229,7 @@ func (check *Check) SetResultSkipped(reason string) {
}

check.Result = CheckResultSkipped
check.FailureReason = reason
check.SkipReason = reason
}

func (check *Check) SetResultError(reason string) {
Expand All @@ -244,15 +245,15 @@ func (check *Check) SetResultError(reason string) {
return
}
check.Result = CheckResultError
check.FailureReason = reason
check.SkipReason = reason
}

func (check *Check) SetResultAborted(reason string) {
check.mutex.Lock()
defer check.mutex.Unlock()

check.Result = CheckResultAborted
check.FailureReason = reason
check.SkipReason = reason
}

func (check *Check) Run() error {
Expand Down
5 changes: 3 additions & 2 deletions pkg/checksdb/checksdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ func recordCheckResult(check *Check) {
StartTime: check.StartTime.String(),
EndTime: check.EndTime.String(),
Duration: int(check.EndTime.Sub(check.StartTime).Seconds()),
FailureReason: check.FailureReason,
CapturedTestOutput: check.CapturedOutput,
SkipReason: check.SkipReason,
CapturedTestOutput: check.GetLogs(),
CheckDetails: check.Details,

CategoryClassification: &claim.CategoryClassification{
Extended: identifiers.Catalog[claimID].CategoryClassification[identifiers.Extended],
Expand Down
3 changes: 2 additions & 1 deletion pkg/claimhelper/claimhelper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ func TestPopulateXMLFromClaim(t *testing.T) {
Suite: testSuiteName,
},
State: "failed",
FailureReason: failureMessage,
SkipReason: failureMessage,
CheckDetails: "",
CapturedTestOutput: "test output",
CategoryClassification: &claim.CategoryClassification{
Extended: "false",
Expand Down

0 comments on commit 997c019

Please sign in to comment.