restic/internal/backend/swift/config_test.go

57 lines
1010 B
Go
Raw Normal View History

package swift
import (
"testing"
"github.com/restic/restic/internal/backend/test"
)
var configTests = []test.ConfigTestData[Config]{
2017-06-05 22:33:25 +00:00
{
2023-04-21 19:11:33 +00:00
S: "swift:cnt1:/",
Cfg: Config{
2017-06-05 22:33:25 +00:00
Container: "cnt1",
Prefix: "",
Connections: 5,
2017-06-05 22:33:25 +00:00
},
},
{
2023-04-21 19:11:33 +00:00
S: "swift:cnt2:/prefix",
Cfg: Config{Container: "cnt2",
2017-06-05 22:33:25 +00:00
Prefix: "prefix",
Connections: 5,
2017-06-05 22:33:25 +00:00
},
},
{
2023-04-21 19:11:33 +00:00
S: "swift:cnt3:/prefix/longer",
Cfg: Config{Container: "cnt3",
2017-06-05 22:33:25 +00:00
Prefix: "prefix/longer",
Connections: 5,
2017-06-05 22:33:25 +00:00
},
},
}
2017-05-01 08:13:03 +00:00
func TestParseConfig(t *testing.T) {
test.ParseConfigTester(t, ParseConfig, configTests)
}
var configTestsInvalid = []string{
"swift://hostname/container",
"swift:////",
"swift://",
"swift:////prefix",
"swift:container",
"swift:container:",
"swift:container/prefix",
}
func TestParseConfigInvalid(t *testing.T) {
for i, test := range configTestsInvalid {
_, err := ParseConfig(test)
if err == nil {
t.Errorf("test %d: invalid config %s did not return an error", i, test)
continue
}
}
}