Skip to content

Commit

Permalink
refactor: rename file implementing reporter (#95)
Browse files Browse the repository at this point in the history
Signed-off-by: Tronje Krop <tronje.krop@zalando.de>
  • Loading branch information
tkrop committed Oct 20, 2024
1 parent f23b9cf commit 038c44c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
8 changes: 4 additions & 4 deletions test/caller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
23 changes: 0 additions & 23 deletions test/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
23 changes: 23 additions & 0 deletions test/gomock.go → test/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.

0 comments on commit 038c44c

Please sign in to comment.