Skip to content

Commit

Permalink
use a pkg var for ErrNoValidBackends
Browse files Browse the repository at this point in the history
Signed-off-by: James Ranson <[email protected]>
  • Loading branch information
jranson committed May 18, 2024
1 parent 3922ed7 commit c363908
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions pkg/config/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package config

import "errors"

var ErrNoValidBackends = errors.New("no valid backends configured")
3 changes: 1 addition & 2 deletions pkg/config/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package config

import (
"errors"
"net/url"
"time"

Expand Down Expand Up @@ -72,7 +71,7 @@ func Load(applicationName string, applicationVersion string, arguments []string)
}

if len(c.Backends) == 0 {
return nil, flags, errors.New("no valid backends configured")
return nil, flags, ErrNoValidBackends
}

ncl, err := negative.ConfigLookup(c.NegativeCacheConfigs).Validate()
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ func TestLoadConfigurationWarning2(t *testing.T) {
func TestLoadEmptyArgs(t *testing.T) {
a := []string{}
_, _, err := Load("trickster-test", "0", a)
if err == nil {
t.Error("expected error: no valid backends configured")
if err != ErrNoValidBackends {
t.Error("expected error:", ErrNoValidBackends)
}
}

0 comments on commit c363908

Please sign in to comment.