mirror of
https://github.com/restic/restic.git
synced 2025-12-04 00:01:48 +00:00
backend: Hardcode backend scheme in Factory
Our ParseConfig implementations always expect a specific scheme, thus no other scheme would work.
This commit is contained in:
@@ -14,6 +14,7 @@ type testConfig struct {
|
||||
|
||||
func testFactory() location.Factory {
|
||||
return location.NewHTTPBackendFactory[testConfig, restic.Backend](
|
||||
"local",
|
||||
func(s string) (*testConfig, error) {
|
||||
return &testConfig{loc: s}, nil
|
||||
}, nil, nil, nil,
|
||||
@@ -22,12 +23,12 @@ func testFactory() location.Factory {
|
||||
|
||||
func TestParse(t *testing.T) {
|
||||
registry := location.NewRegistry()
|
||||
registry.Register("test", testFactory())
|
||||
registry.Register(testFactory())
|
||||
|
||||
path := "test:example"
|
||||
path := "local:example"
|
||||
u, err := location.Parse(registry, path)
|
||||
test.OK(t, err)
|
||||
test.Equals(t, "test", u.Scheme)
|
||||
test.Equals(t, "local", u.Scheme)
|
||||
test.Equals(t, &testConfig{loc: path}, u.Config)
|
||||
}
|
||||
|
||||
@@ -43,7 +44,7 @@ func TestParseFallback(t *testing.T) {
|
||||
}
|
||||
|
||||
registry := location.NewRegistry()
|
||||
registry.Register("local", testFactory())
|
||||
registry.Register(testFactory())
|
||||
|
||||
for _, path := range fallbackTests {
|
||||
t.Run(path, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user