2015-12-28 14:51:24 +00:00
|
|
|
package s3
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
2015-12-28 14:57:20 +00:00
|
|
|
var configTests = []struct {
|
2015-12-28 14:51:24 +00:00
|
|
|
s string
|
|
|
|
cfg Config
|
|
|
|
}{
|
|
|
|
{"s3://eu-central-1/bucketname", Config{
|
2015-12-28 17:23:02 +00:00
|
|
|
Region: "eu-central-1",
|
2015-12-28 14:51:24 +00:00
|
|
|
Bucket: "bucketname",
|
|
|
|
}},
|
2015-12-28 17:23:02 +00:00
|
|
|
{"s3:eu-central-1/foobar", Config{
|
|
|
|
Region: "eu-central-1",
|
|
|
|
Bucket: "foobar",
|
|
|
|
}},
|
|
|
|
{"s3:https://hostname:9999/foobar", Config{
|
|
|
|
URL: "https://hostname:9999",
|
|
|
|
Bucket: "foobar",
|
|
|
|
}},
|
|
|
|
{"s3:http://hostname:9999/foobar", Config{
|
|
|
|
URL: "http://hostname:9999",
|
2015-12-28 14:51:24 +00:00
|
|
|
Bucket: "foobar",
|
|
|
|
}},
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseConfig(t *testing.T) {
|
2015-12-28 14:57:20 +00:00
|
|
|
for i, test := range configTests {
|
2015-12-28 14:51:24 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|