mirror of
https://github.com/restic/restic.git
synced 2025-12-08 06:09:56 +00:00
Add repository location parsing code
This commit is contained in:
parent
43cf95e3c6
commit
566a15285a
7 changed files with 370 additions and 0 deletions
33
backend/s3/uri_test.go
Normal file
33
backend/s3/uri_test.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package s3
|
||||
|
||||
import "testing"
|
||||
|
||||
var uriTests = []struct {
|
||||
s string
|
||||
cfg Config
|
||||
}{
|
||||
{"s3://eu-central-1/bucketname", Config{
|
||||
Host: "eu-central-1",
|
||||
Bucket: "bucketname",
|
||||
}},
|
||||
{"s3:hostname:foobar", Config{
|
||||
Host: "hostname",
|
||||
Bucket: "foobar",
|
||||
}},
|
||||
}
|
||||
|
||||
func TestParseConfig(t *testing.T) {
|
||||
for i, test := range uriTests {
|
||||
cfg, err := ParseConfig(test.s)
|
||||
if err != nil {
|
||||
t.Errorf("test %d failed: %v", i, err)
|
||||
continue
|
||||
}
|
||||
|
||||
if cfg != test.cfg {
|
||||
t.Errorf("test %d: wrong config, want:\n %v\ngot:\n %v",
|
||||
i, test.cfg, cfg)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue