backend: use generic implementation for ParseConfig tests

This commit is contained in:
Michael Eischer 2023-04-20 23:02:56 +02:00
parent 5260d38980
commit fa361dbfbd
9 changed files with 88 additions and 157 deletions

View file

@ -1,37 +1,24 @@
package rclone
import (
"reflect"
"testing"
"github.com/restic/restic/internal/backend/test"
)
func TestParseConfig(t *testing.T) {
var tests = []struct {
s string
cfg Config
}{
{
"rclone:local:foo:/bar",
Config{
Remote: "local:foo:/bar",
Program: defaultConfig.Program,
Args: defaultConfig.Args,
Connections: defaultConfig.Connections,
Timeout: defaultConfig.Timeout,
},
var configTests = []test.ConfigTestData[Config]{
{
"rclone:local:foo:/bar",
Config{
Remote: "local:foo:/bar",
Program: defaultConfig.Program,
Args: defaultConfig.Args,
Connections: defaultConfig.Connections,
Timeout: defaultConfig.Timeout,
},
}
for _, test := range tests {
t.Run("", func(t *testing.T) {
cfg, err := ParseConfig(test.s)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(cfg, test.cfg) {
t.Fatalf("wrong config, want:\n %v\ngot:\n %v", test.cfg, cfg)
}
})
}
},
}
func TestParseConfig(t *testing.T) {
test.ParseConfigTester(t, ParseConfig, configTests)
}