Skip to content

Commit

Permalink
Review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsheepuk committed Apr 29, 2024
1 parent dbb8426 commit 939bd89
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions testingt.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func Logf(ctx context.Context, format string, args ...interface{}) {
t.Logf(format, args...)
return
}
fallbackLogf(format, args...)
fmt.Printf(format+"\n", args...)
}

// Log will log test output. If called in the context of a test and testing.T has been registered,
Expand All @@ -67,7 +67,7 @@ func Log(ctx context.Context, args ...interface{}) {
t.Log(args...)
return
}
fallbackLog(args...)
fmt.Println(args...)
}

// LoggedMessages returns an array of any logged messages that have been recorded during the test
Expand Down Expand Up @@ -95,8 +95,6 @@ type testingT struct {
// check interface against our testingT and the upstream testing.B/F/T:
var (
_ TestingT = &testingT{}
_ TestingT = (*testing.B)(nil)
_ TestingT = (*testing.F)(nil)
_ TestingT = (*testing.T)(nil)
)

Expand All @@ -113,7 +111,7 @@ func (dt *testingT) Log(args ...interface{}) {
dt.t.Log(args...)
return
}
fallbackLog(args...)
fmt.Println(args...)
}

func (dt *testingT) Logf(format string, args ...interface{}) {
Expand All @@ -122,7 +120,7 @@ func (dt *testingT) Logf(format string, args ...interface{}) {
dt.t.Logf(format, args...)
return
}
fallbackLogf(format, args...)
fmt.Printf(format+"\n", args...)
}

func (dt *testingT) Error(args ...interface{}) {
Expand Down Expand Up @@ -206,13 +204,3 @@ func getTestingT(ctx context.Context) *testingT {
}
return dt
}

// fallbackLog is used to log when no testing.T is available. Set as a variable so this can be
// disabled / re-routed in future if needed.
var fallbackLog = fmt.Println

// fallbackLogf is used to log a formatted string when no testing.T is available. Set as a variable
// so this can be disabled / re-routed in future if needed.
var fallbackLogf = func(message string, args ...interface{}) {
fmt.Printf(message+"\n", args...)
}

0 comments on commit 939bd89

Please sign in to comment.