backend: Adjust tests to use the Factory to instantiate the backend
This drastically reduces the amount of duplicated test code.
This commit is contained in:
parent
3d3bb88745
commit
13a8b5822f
13 changed files with 119 additions and 423 deletions
|
@ -6,10 +6,12 @@ import (
|
|||
"encoding/base64"
|
||||
"hash"
|
||||
"io"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"github.com/cespare/xxhash/v2"
|
||||
"github.com/restic/restic/internal/backend"
|
||||
"github.com/restic/restic/internal/backend/location"
|
||||
"github.com/restic/restic/internal/debug"
|
||||
"github.com/restic/restic/internal/errors"
|
||||
"github.com/restic/restic/internal/restic"
|
||||
|
@ -20,6 +22,24 @@ type memMap map[restic.Handle][]byte
|
|||
// make sure that MemoryBackend implements backend.Backend
|
||||
var _ restic.Backend = &MemoryBackend{}
|
||||
|
||||
// NewFactory creates a persistent mem backend
|
||||
func NewFactory() location.Factory {
|
||||
be := New()
|
||||
|
||||
return location.NewHTTPBackendFactory[struct{}, *MemoryBackend](
|
||||
func(s string) (*struct{}, error) {
|
||||
return &struct{}{}, nil
|
||||
},
|
||||
location.NoPassword,
|
||||
func(_ context.Context, _ struct{}, _ http.RoundTripper) (*MemoryBackend, error) {
|
||||
return be, nil
|
||||
},
|
||||
func(_ context.Context, _ struct{}, _ http.RoundTripper) (*MemoryBackend, error) {
|
||||
return be, nil
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
var errNotFound = errors.New("not found")
|
||||
|
||||
const connectionCount = 2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue