mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 19:08:55 +00:00
ba75a3884c
Environment variables:
GOOGLE_PROJECT_ID=gcp-project-id
GOOGLE_APPLICATION_CREDENTIALS=path-to-json-file
Environment variables for test:
RESTIC_TEST_GS_PROJECT_ID=gcp-project-id
RESTIC_TEST_GS_APPLICATION_CREDENTIALS=path-to-json-file
RESTIC_TEST_GS_REPOSITORY=gs:us-central1/test-bucket
Init repository:
$ restic -r gs🪣/[prefix] init
41 lines
801 B
Go
41 lines
801 B
Go
package gs
|
|
|
|
import "testing"
|
|
|
|
var configTests = []struct {
|
|
s string
|
|
cfg Config
|
|
}{
|
|
{"gs:bucketname:/", Config{
|
|
Bucket: "bucketname",
|
|
Prefix: "",
|
|
Connections: 5,
|
|
}},
|
|
{"gs:bucketname:/prefix/directory", Config{
|
|
Bucket: "bucketname",
|
|
Prefix: "prefix/directory",
|
|
Connections: 5,
|
|
}},
|
|
{"gs:bucketname:/prefix/directory/", Config{
|
|
Bucket: "bucketname",
|
|
Prefix: "prefix/directory",
|
|
Connections: 5,
|
|
}},
|
|
}
|
|
|
|
func TestParseConfig(t *testing.T) {
|
|
for i, test := range configTests {
|
|
cfg, err := ParseConfig(test.s)
|
|
if err != nil {
|
|
t.Errorf("test %d:%s failed: %v", i, test.s, err)
|
|
continue
|
|
}
|
|
|
|
if cfg != test.cfg {
|
|
t.Errorf("test %d:\ninput:\n %s\n wrong config, want:\n %v\ngot:\n %v",
|
|
i, test.s, test.cfg, cfg)
|
|
continue
|
|
}
|
|
}
|
|
}
|