Skip to content

Commit

Permalink
Update coverage config
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Jogeleit <[email protected]>
  • Loading branch information
Frank Jogeleit committed Apr 24, 2024
1 parent feb0548 commit 39fc42a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 46 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ test:

.PHONY: coverage
coverage:
go test -v ./... -covermode=count -coverprofile=coverage.out -timeout=30s
go test -v ./... -covermode=count -coverprofile=coverage.out.tmp -timeout=30s
cat coverage.out.tmp | grep -v "github.com/kyverno/policy-reporter/cmd/" | grep -v "github.com/kyverno/policy-reporter/main.go" | grep -v "github.com/kyverno/policy-reporter/pkg/crd/" > coverage.out
rm coverage.out.tmp

.PHONY: build
build: prepare
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,26 @@ func TestClusterPolicyReport(t *testing.T) {
t.Errorf("expected critical severity, got: %s", cpolr.GetSeverities()[1])
}
})
t.Run("Results", func(t *testing.T) {
polr := &v1alpha2.ClusterPolicyReport{}

if s := len(polr.GetResults()); s != 0 {
t.Errorf("expected empty results, got: %d", s)
}

polr.SetResults([]v1alpha2.PolicyReportResult{
{Policy: "require-label", Result: v1alpha2.StatusPass},
})

if s := len(polr.GetResults()); s != 1 {
t.Errorf("expected 1 result, got: %d", s)
}
})
t.Run("Summary", func(t *testing.T) {
polr := &v1alpha2.ClusterPolicyReport{Summary: v1alpha2.PolicyReportSummary{Pass: 1}}

if s := polr.GetSummary().Pass; s != 1 {
t.Errorf("expected 1 pass result, got: %d", s)
}
})
}
22 changes: 22 additions & 0 deletions pkg/crd/api/policyreport/v1alpha2/policyreport_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,26 @@ func TestPolicyReport(t *testing.T) {
t.Errorf("expected critical severity, got: %s", cpolr.GetSeverities()[1])
}
})
t.Run("Results", func(t *testing.T) {
polr := &v1alpha2.PolicyReport{}

if s := len(polr.GetResults()); s != 0 {
t.Errorf("expected empty results, got: %d", s)
}

polr.SetResults([]v1alpha2.PolicyReportResult{
{Policy: "require-label", Result: v1alpha2.StatusPass},
})

if s := len(polr.GetResults()); s != 1 {
t.Errorf("expected 1 result, got: %d", s)
}
})
t.Run("Summary", func(t *testing.T) {
polr := &v1alpha2.PolicyReport{Summary: v1alpha2.PolicyReportSummary{Pass: 1}}

if s := polr.GetSummary().Pass; s != 1 {
t.Errorf("expected 1 pass result, got: %d", s)
}
})
}
45 changes: 0 additions & 45 deletions pkg/crd/api/policyreport/v1alpha2/util.go

This file was deleted.

0 comments on commit 39fc42a

Please sign in to comment.