mirror of
https://github.com/restic/restic.git
synced 2025-03-16 00:00:05 +01:00

Implemented Google Cloud Storage support using the existing minio libraries. GCS repositories get specified using gs://bucketname/prefix syntax. Cloned the existing S3 support and tests to use them for GCS as well. Added tests for the various cases to config_test and location_test. Remove trailing slashes in repository specification.
65 lines
1.4 KiB
Go
65 lines
1.4 KiB
Go
package gcs
|
|
|
|
import "testing"
|
|
|
|
var configTests = []struct {
|
|
s string
|
|
cfg Config
|
|
}{
|
|
{"gs://bucketname", Config{
|
|
Endpoint: "storage.googleapis.com",
|
|
Bucket: "bucketname",
|
|
Prefix: "restic",
|
|
}},
|
|
{"gs://bucketname/", Config{
|
|
Endpoint: "storage.googleapis.com",
|
|
Bucket: "bucketname",
|
|
Prefix: "restic",
|
|
}},
|
|
{"gs://bucketname/prefix/dir", Config{
|
|
Endpoint: "storage.googleapis.com",
|
|
Bucket: "bucketname",
|
|
Prefix: "prefix/dir",
|
|
}},
|
|
{"gs://bucketname/prefix/dir/", Config{
|
|
Endpoint: "storage.googleapis.com",
|
|
Bucket: "bucketname",
|
|
Prefix: "prefix/dir",
|
|
}},
|
|
{"gs:bucketname", Config{
|
|
Endpoint: "storage.googleapis.com",
|
|
Bucket: "bucketname",
|
|
Prefix: "restic",
|
|
}},
|
|
{"gs:bucketname/", Config{
|
|
Endpoint: "storage.googleapis.com",
|
|
Bucket: "bucketname",
|
|
Prefix: "restic",
|
|
}},
|
|
{"gs:bucketname/prefix/dir", Config{
|
|
Endpoint: "storage.googleapis.com",
|
|
Bucket: "bucketname",
|
|
Prefix: "prefix/dir",
|
|
}},
|
|
{"gs:bucketname/prefix/dir/", Config{
|
|
Endpoint: "storage.googleapis.com",
|
|
Bucket: "bucketname",
|
|
Prefix: "prefix/dir",
|
|
}},
|
|
}
|
|
|
|
func TestParseConfig(t *testing.T) {
|
|
for i, test := range configTests {
|
|
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
|
|
}
|
|
}
|
|
}
|