From f41f5539b7a7eefdf5e08ef92abbe512a4606c52 Mon Sep 17 00:00:00 2001 From: Adam Leclerc Date: Fri, 22 Nov 2024 10:07:29 -0400 Subject: [PATCH] Remove systemout reporter --- approval_name.go | 4 ++++ reporters/continuous_integration.go | 5 ++--- reporters/systemout_reporter.go | 35 ----------------------------- 3 files changed, 6 insertions(+), 38 deletions(-) delete mode 100644 reporters/systemout_reporter.go diff --git a/approval_name.go b/approval_name.go index dfb9145..041f27f 100644 --- a/approval_name.go +++ b/approval_name.go @@ -69,6 +69,10 @@ func findFileName() (*string, error) { return nil, fmt.Errorf("approvals: could not find the test method") } + if lastFrame == nil { + return nil, fmt.Errorf("approvals: could not find the last frame") + } + return &lastFrame.File, nil } diff --git a/reporters/continuous_integration.go b/reporters/continuous_integration.go index a61efa9..923feb7 100644 --- a/reporters/continuous_integration.go +++ b/reporters/continuous_integration.go @@ -19,9 +19,8 @@ func (s *continuousIntegration) Report(approved, received string) bool { if exists { ci, err := strconv.ParseBool(value) - if err == nil && ci { - systemout := NewSystemoutReporter() - return systemout.Report(approved, received) + if err == nil { + return ci } } diff --git a/reporters/systemout_reporter.go b/reporters/systemout_reporter.go deleted file mode 100644 index e0bfa4d..0000000 --- a/reporters/systemout_reporter.go +++ /dev/null @@ -1,35 +0,0 @@ -package reporters - -import ( - "fmt" - "path/filepath" - - "github.com/approvals/go-approval-tests/utils" -) - -type systemout struct{} - -// NewQuietReporter creates a new reporter that does nothing. -func NewSystemoutReporter() Reporter { - return &systemout{} -} - -func (s *systemout) Report(approved, received string) bool { - approvedFull, _ := filepath.Abs(approved) - receivedFull, _ := filepath.Abs(received) - - fmt.Printf("approval files did not match\napproved: %v\nreceived: %v\n", approvedFull, receivedFull) - - printFileContent("Received", receivedFull) - printFileContent("Approved", approvedFull) - - return true -} - -func printFileContent(label, path string) { - content, err := utils.ReadFile(path) - if err != nil { - content = fmt.Sprintf("** Error reading %s file **", label) - } - fmt.Printf("%s content:\n%s\n", label, content) -}