fstests: add TestInternal (#2085)

TestInternal allows to perform a custom test on the backend using the
optional InternalTester interface.
This commit is contained in:
Fabian Möller
2018-02-25 10:58:06 +01:00
committed by GitHub
parent 9252224d82
commit aeefa34f62
23 changed files with 39 additions and 0 deletions
+17
View File
@@ -57,6 +57,13 @@ var (
isLocalRemote bool
)
// InternalTester is an optional interface for Fs which allows to execute internal tests
//
// This interface should be implemented in 'backend'_internal_test.go and not in 'backend'.go
type InternalTester interface {
InternalTest(*testing.T)
}
// ExtraConfigItem describes a config item added on the fly while testing
type ExtraConfigItem struct{ Name, Key, Value string }
@@ -970,6 +977,16 @@ func TestObjectPurge(t *testing.T) {
assert.Error(t, err, "Expecting error after on second purge")
}
// TestInternal calls InternalTest() on the Fs
func TestInternal(t *testing.T) {
skipIfNotOk(t)
if it, ok := remote.(InternalTester); ok {
it.InternalTest(t)
} else {
t.Skipf("%T does not implement InternalTester", remote)
}
}
// TestFinalise tidies up after the previous tests
func TestFinalise(t *testing.T) {
skipIfNotOk(t)