From c36390882a29cbf541b509c39e02ee3c2095796d Mon Sep 17 00:00:00 2001 From: James Ranson Date: Sat, 18 May 2024 15:51:42 -0600 Subject: [PATCH] use a pkg var for ErrNoValidBackends Signed-off-by: James Ranson --- pkg/config/errors.go | 5 +++++ pkg/config/loader.go | 3 +-- pkg/config/loader_test.go | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 pkg/config/errors.go diff --git a/pkg/config/errors.go b/pkg/config/errors.go new file mode 100644 index 000000000..a1e00a412 --- /dev/null +++ b/pkg/config/errors.go @@ -0,0 +1,5 @@ +package config + +import "errors" + +var ErrNoValidBackends = errors.New("no valid backends configured") diff --git a/pkg/config/loader.go b/pkg/config/loader.go index c5946f13b..ef48206e5 100644 --- a/pkg/config/loader.go +++ b/pkg/config/loader.go @@ -17,7 +17,6 @@ package config import ( - "errors" "net/url" "time" @@ -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() diff --git a/pkg/config/loader_test.go b/pkg/config/loader_test.go index 769dd71a7..8a128cb92 100644 --- a/pkg/config/loader_test.go +++ b/pkg/config/loader_test.go @@ -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) } }