Add repository location parsing code

This commit is contained in:
Alexander Neumann 2015-12-28 15:51:24 +01:00
parent 43cf95e3c6
commit 566a15285a
7 changed files with 370 additions and 0 deletions

33
backend/s3/uri_test.go Normal file
View 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
}
}
}