Skip to content

Commit

Permalink
Fix scorecard test failures
Browse files Browse the repository at this point in the history
* Trim deprecation warning before unmarshalling output.

Signed-off-by: Neo2308 <pradha.krishna.cse17@itbhu.ac.in>
  • Loading branch information
Neo2308 committed Sep 2, 2023
1 parent fcc10c8 commit 04549ed
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions test/common/scorecard.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func ScorecardSpec(tc *testutils.TestContext, operatorType string) func() {
"--wait-time", "2m")
outputBytes, err = tc.Run(cmd)
Expect(err).NotTo(HaveOccurred())
Expect(json.Unmarshal(outputBytes, &output)).To(Succeed())
Expect(json.Unmarshal(trimmedOutput(outputBytes), &output)).To(Succeed())

Expect(output.Items).To(HaveLen(1))
results := output.Items[0].Status.Results
Expand All @@ -63,7 +63,7 @@ func ScorecardSpec(tc *testutils.TestContext, operatorType string) func() {
if strings.ToLower(operatorType) != "go" {
Expect(err).To(HaveOccurred())
}
Expect(json.Unmarshal(outputBytes, &output)).To(Succeed())
Expect(json.Unmarshal(trimmedOutput(outputBytes), &output)).To(Succeed())

expected := map[string]v1alpha3.State{
// Basic suite.
Expand Down Expand Up @@ -110,7 +110,7 @@ func ScorecardSpec(tc *testutils.TestContext, operatorType string) func() {
"--wait-time", "4m")
outputBytes, err = tc.Run(cmd)
Expect(err).NotTo(HaveOccurred())
Expect(json.Unmarshal(outputBytes, &output)).To(Succeed())
Expect(json.Unmarshal(trimmedOutput(outputBytes), &output)).To(Succeed())

Expect(output.Items).To(HaveLen(1))
results := output.Items[0].Status.Results
Expand All @@ -120,3 +120,10 @@ func ScorecardSpec(tc *testutils.TestContext, operatorType string) func() {
})
}
}

// trimmedOutput trims the deprecation message (if present) from the output
func trimmedOutput(output []byte) []byte {
outputStr := string(output)
index := strings.Index(outputStr, "{")
return []byte(outputStr[index:])
}

0 comments on commit 04549ed

Please sign in to comment.