mirror of
https://github.com/restic/restic.git
synced 2025-12-04 00:31:48 +00:00
move Backend interface to backend package
This commit is contained in:
38
internal/backend/backend_test.go
Normal file
38
internal/backend/backend_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package backend_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/restic/restic/internal/backend"
|
||||
"github.com/restic/restic/internal/test"
|
||||
)
|
||||
|
||||
type testBackend struct {
|
||||
backend.Backend
|
||||
}
|
||||
|
||||
func (t *testBackend) Unwrap() backend.Backend {
|
||||
return nil
|
||||
}
|
||||
|
||||
type otherTestBackend struct {
|
||||
backend.Backend
|
||||
}
|
||||
|
||||
func (t *otherTestBackend) Unwrap() backend.Backend {
|
||||
return t.Backend
|
||||
}
|
||||
|
||||
func TestAsBackend(t *testing.T) {
|
||||
other := otherTestBackend{}
|
||||
test.Assert(t, backend.AsBackend[*testBackend](other) == nil, "otherTestBackend is not a testBackend backend")
|
||||
|
||||
testBe := &testBackend{}
|
||||
test.Assert(t, backend.AsBackend[*testBackend](testBe) == testBe, "testBackend was not returned")
|
||||
|
||||
wrapper := &otherTestBackend{Backend: testBe}
|
||||
test.Assert(t, backend.AsBackend[*testBackend](wrapper) == testBe, "failed to unwrap testBackend backend")
|
||||
|
||||
wrapper.Backend = other
|
||||
test.Assert(t, backend.AsBackend[*testBackend](wrapper) == nil, "a wrapped otherTestBackend is not a testBackend")
|
||||
}
|
||||
Reference in New Issue
Block a user