mirror of
https://github.com/restic/restic.git
synced 2026-08-16 18:43:19 +00:00
Add test.Helper, also works with Go 1.8
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
// +build go1.9
|
||||
|
||||
package test
|
||||
|
||||
import "testing"
|
||||
|
||||
// Helperer marks the current function as a test helper.
|
||||
type Helperer interface {
|
||||
Helper()
|
||||
}
|
||||
|
||||
// Helper returns a function that marks the current function as a helper function.
|
||||
func Helper(t testing.TB) Helperer {
|
||||
return t
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// +build !go1.9
|
||||
|
||||
package test
|
||||
|
||||
import "testing"
|
||||
|
||||
// Helperer marks the current function as a test helper.
|
||||
type Helperer interface {
|
||||
Helper()
|
||||
}
|
||||
|
||||
type fakeHelper struct{}
|
||||
|
||||
func (fakeHelper) Helper() {}
|
||||
|
||||
// Helper returns a function that marks the current function as a helper function.
|
||||
func Helper(t testing.TB) Helperer {
|
||||
return fakeHelper{}
|
||||
}
|
||||
Reference in New Issue
Block a user