From 038c44c521d6c996c837e98d023ce1a44c97ef80 Mon Sep 17 00:00:00 2001 From: Tronje Krop Date: Mon, 21 Oct 2024 00:19:03 +0200 Subject: [PATCH] refactor: rename file implementing reporter (#95) Signed-off-by: Tronje Krop --- test/caller_test.go | 8 ++++---- test/context.go | 23 ----------------------- test/{gomock.go => reporter.go} | 23 +++++++++++++++++++++++ test/{gomock_test.go => reporter_test.go} | 0 4 files changed, 27 insertions(+), 27 deletions(-) rename test/{gomock.go => reporter.go} (91%) rename test/{gomock_test.go => reporter_test.go} (100%) diff --git a/test/caller_test.go b/test/caller_test.go index 15fa4c9..c897896 100644 --- a/test/caller_test.go +++ b/test/caller_test.go @@ -131,15 +131,15 @@ var ( }() // CallerTestError provides the file with the line number of the `Error` // call in the test context implementation. - CallerTestError = path.Join(SourceDir, "context.go:356") + CallerTestError = path.Join(SourceDir, "context.go:333") // CallerReporterErrorf provides the file with the line number of the // `Errorf` call in the test reporter/validator implementation. - CallerReporterError = path.Join(SourceDir, "gomock.go:60") + CallerReporterError = path.Join(SourceDir, "reporter.go:83") // CallerTestErrorf provides the file with the line number of the `Errorf` // call in the test context implementation. - CallerTestErrorf = path.Join(SourceDir, "context.go:374") + CallerTestErrorf = path.Join(SourceDir, "context.go:351") // CallerReporterErrorf provides the file with the line number of the // `Errorf` call in the test reporter/validator implementation. - CallerReporterErrorf = path.Join(SourceDir, "gomock.go:82") + CallerReporterErrorf = path.Join(SourceDir, "reporter.go:105") ) diff --git a/test/context.go b/test/context.go index df6d17c..63cdd0f 100644 --- a/test/context.go +++ b/test/context.go @@ -65,29 +65,6 @@ type Test interface { //nolint:interfacebloat // Minimal interface. Cleanup(cleanup func()) } -// Reporter is a minimal interface for abstracting test report methods that are -// needed to setup an isolated test environment for GoMock and Testify. -type Reporter interface { - // Error reports a failure messages when a test is supposed to continue. - Error(args ...any) - // Errorf reports a failure messages when a test is supposed to continue. - Errorf(format string, args ...any) - // Fatal reports a fatal failure message that immediate aborts of the test - // execution. - Fatal(args ...any) - // Fatalf reports a fatal failure message that immediate aborts of the test - // execution. - Fatalf(format string, args ...any) - // Fail reports a failure message that immediate aborts of the test - // execution. - Fail() - // FailNow reports fatal failure notifications without log output that - // aborts test execution immediately. - FailNow() - // Panic reports a panic. - Panic(arg any) -} - // Cleanuper defines an interface to add a custom mehtod that is called after // the test execution to cleanup the test environment. type Cleanuper interface { diff --git a/test/gomock.go b/test/reporter.go similarity index 91% rename from test/gomock.go rename to test/reporter.go index 0ffd280..6550f1d 100644 --- a/test/gomock.go +++ b/test/reporter.go @@ -9,6 +9,29 @@ import ( "github.com/tkrop/go-testing/mock" ) +// Reporter is a minimal interface for abstracting test report methods that are +// needed to setup an isolated test environment for GoMock and Testify. +type Reporter interface { + // Error reports a failure messages when a test is supposed to continue. + Error(args ...any) + // Errorf reports a failure messages when a test is supposed to continue. + Errorf(format string, args ...any) + // Fatal reports a fatal failure message that immediate aborts of the test + // execution. + Fatal(args ...any) + // Fatalf reports a fatal failure message that immediate aborts of the test + // execution. + Fatalf(format string, args ...any) + // Fail reports a failure message that immediate aborts of the test + // execution. + Fail() + // FailNow reports fatal failure notifications without log output that + // aborts test execution immediately. + FailNow() + // Panic reports a panic. + Panic(arg any) +} + // Validator a test failure validator based on the test reporter interface. type Validator struct { ctrl *gomock.Controller diff --git a/test/gomock_test.go b/test/reporter_test.go similarity index 100% rename from test/gomock_test.go rename to test/reporter_test.go