Skip to content

Commit

Permalink
Refactor Report Name function (#404)
Browse files Browse the repository at this point in the history
Signed-off-by: Ken Sipe <kensipe@gmail.com>
  • Loading branch information
kensipe authored Nov 9, 2022
1 parent 81994a4 commit a9b9189
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions pkg/test/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,18 +602,17 @@ func (h *Harness) Report() {
if len(h.TestSuite.ReportFormat) == 0 {
return
}
if err := h.report.Report(h.TestSuite.ArtifactsDir, h.GetReportName(), report.Type(h.TestSuite.ReportFormat)); err != nil {
if err := h.report.Report(h.TestSuite.ArtifactsDir, h.reportName(), report.Type(h.TestSuite.ReportFormat)); err != nil {
h.fatal(fmt.Errorf("fatal error writing report: %v", err))
}
}

// GetReportName returns the configured ReportName.
func (h *Harness) GetReportName() string {
reportName := "kuttl-report"
// reportName returns the configured ReportName.
func (h *Harness) reportName() string {
if h.TestSuite.ReportName != "" {
reportName = h.TestSuite.ReportName
return h.TestSuite.ReportName
}
return reportName
return "kuttl-report"
}

func (h *Harness) loadKindConfig(path string) (*kindConfig.Cluster, error) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/test/harness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ func TestGetTimeout(t *testing.T) {

func TestGetReportName(t *testing.T) {
h := Harness{}
assert.Equal(t, "kuttl-report", h.GetReportName())
assert.Equal(t, "kuttl-report", h.reportName())

h.TestSuite.ReportName = "special-kuttl-report"
assert.Equal(t, "special-kuttl-report", h.GetReportName())
assert.Equal(t, "special-kuttl-report", h.reportName())
}

type dockerMock struct {
Expand Down

0 comments on commit a9b9189

Please sign in to comment.