mirror of
https://github.com/restic/restic.git
synced 2026-11-22 05:14:23 +00:00
backend: let ParseConfig return a Config pointer
In order to change the backend initialization in `global.go` to be able
to generically call cfg.ApplyEnvironment() for supported backends, the
`interface{}` returned by `ParseConfig` must contain a pointer to the
configuration.
An alternative would be to use reflection to convert the type from
`interface{}(Config)` to `interface{}(*Config)` (from value to pointer
type). However, this would just complicate the type mess further.
This commit is contained in:
1 parent
25a0be7f26
commit
f903db492c
26 files changed
+165
-146
No files matched your search
@@ -11,7 +11,7 @@ type ConfigTestData[C comparable] struct {
|
||||
Cfg C
|
||||
}
|
||||
|
||||
func ParseConfigTester[C comparable](t *testing.T, parser func(s string) (C, error), tests []ConfigTestData[C]) {
|
||||
func ParseConfigTester[C comparable](t *testing.T, parser func(s string) (*C, error), tests []ConfigTestData[C]) {
|
||||
for i, test := range tests {
|
||||
t.Run(fmt.Sprint(i), func(t *testing.T) {
|
||||
cfg, err := parser(test.S)
|
||||
@@ -19,9 +19,9 @@ func ParseConfigTester[C comparable](t *testing.T, parser func(s string) (C, err
|
||||
t.Fatalf("%s failed: %v", test.S, err)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(cfg, test.Cfg) {
|
||||
if !reflect.DeepEqual(*cfg, test.Cfg) {
|
||||
t.Fatalf("input: %s\n wrong config, want:\n %#v\ngot:\n %#v",
|
||||
test.S, test.Cfg, cfg)
|
||||
test.S, test.Cfg, *cfg)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user