mirror of
https://github.com/restic/restic.git
synced 2026-11-14 14:45:04 +00:00
Rename URI -> Config/Location
This commit is contained in:
1 parent
566a15285a
commit
de933a1d48
7 files changed
+30
-30
No files matched your search
@@ -0,0 +1,85 @@
|
||||
package location
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/restic/restic/backend/s3"
|
||||
"github.com/restic/restic/backend/sftp"
|
||||
)
|
||||
|
||||
var parseTests = []struct {
|
||||
s string
|
||||
u Location
|
||||
}{
|
||||
{"local:/srv/repo", Location{Scheme: "local", Config: "/srv/repo"}},
|
||||
{"local:dir1/dir2", Location{Scheme: "local", Config: "dir1/dir2"}},
|
||||
{"local:dir1/dir2", Location{Scheme: "local", Config: "dir1/dir2"}},
|
||||
{"dir1/dir2", Location{Scheme: "local", Config: "dir1/dir2"}},
|
||||
{"local:../dir1/dir2", Location{Scheme: "local", Config: "../dir1/dir2"}},
|
||||
{"/dir1/dir2", Location{Scheme: "local", Config: "/dir1/dir2"}},
|
||||
|
||||
{"sftp:user@host:/srv/repo", Location{Scheme: "sftp",
|
||||
Config: sftp.Config{
|
||||
User: "user",
|
||||
Host: "host",
|
||||
Dir: "/srv/repo",
|
||||
}}},
|
||||
{"sftp:host:/srv/repo", Location{Scheme: "sftp",
|
||||
Config: sftp.Config{
|
||||
User: "",
|
||||
Host: "host",
|
||||
Dir: "/srv/repo",
|
||||
}}},
|
||||
{"sftp://user@host/srv/repo", Location{Scheme: "sftp",
|
||||
Config: sftp.Config{
|
||||
User: "user",
|
||||
Host: "host",
|
||||
Dir: "srv/repo",
|
||||
}}},
|
||||
{"sftp://user@host//srv/repo", Location{Scheme: "sftp",
|
||||
Config: sftp.Config{
|
||||
User: "user",
|
||||
Host: "host",
|
||||
Dir: "/srv/repo",
|
||||
}}},
|
||||
|
||||
{"s3://eu-central-1/bucketname", Location{Scheme: "s3",
|
||||
Config: s3.Config{
|
||||
Host: "eu-central-1",
|
||||
Bucket: "bucketname",
|
||||
}},
|
||||
},
|
||||
{"s3://hostname.foo/bucketname", Location{Scheme: "s3",
|
||||
Config: s3.Config{
|
||||
Host: "hostname.foo",
|
||||
Bucket: "bucketname",
|
||||
}},
|
||||
},
|
||||
{"s3:hostname.foo:repo", Location{Scheme: "s3",
|
||||
Config: s3.Config{
|
||||
Host: "hostname.foo",
|
||||
Bucket: "repo",
|
||||
}},
|
||||
},
|
||||
}
|
||||
|
||||
func TestParseLocation(t *testing.T) {
|
||||
for i, test := range parseTests {
|
||||
u, err := ParseLocation(test.s)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
if test.u.Scheme != u.Scheme {
|
||||
t.Errorf("test %d: scheme does not match, want %q, got %q",
|
||||
i, test.u.Scheme, u.Scheme)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(test.u.Config, u.Config) {
|
||||
t.Errorf("test %d: cfg map does not match, want:\n %#v\ngot: \n %#v",
|
||||
i, test.u.Config, u.Config)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user