restic/backend/s3/config_test.go

34 lines
577 B
Go
Raw Normal View History

2015-12-28 15:51:24 +01:00
package s3
import "testing"
2015-12-28 15:57:20 +01:00
var configTests = []struct {
2015-12-28 15:51:24 +01:00
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) {
2015-12-28 15:57:20 +01:00
for i, test := range configTests {
2015-12-28 15:51:24 +01: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
}
}
}