backend: let ParseConfig return concrete type

This commit is contained in:
Michael Eischer
2023-04-20 22:40:21 +02:00
parent 2f7b4ceae1
commit 5260d38980
17 changed files with 55 additions and 62 deletions

View File

@@ -26,16 +26,16 @@ func NewConfig() Config {
}
// ParseConfig parses the string s and extracts the REST server URL.
func ParseConfig(s string) (interface{}, error) {
func ParseConfig(s string) (Config, error) {
if !strings.HasPrefix(s, "rest:") {
return nil, errors.New("invalid REST backend specification")
return Config{}, errors.New("invalid REST backend specification")
}
s = prepareURL(s)
u, err := url.Parse(s)
if err != nil {
return nil, errors.WithStack(err)
return Config{}, errors.WithStack(err)
}
cfg := NewConfig()

View File

@@ -130,12 +130,10 @@ func TestBackendRESTExternalServer(t *testing.T) {
t.Fatal(err)
}
c := cfg.(rest.Config)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
newTestSuite(ctx, t, c.URL, true).RunTests(t)
newTestSuite(ctx, t, cfg.URL, true).RunTests(t)
}
func BenchmarkBackendREST(t *testing.B) {