From 63c90deefea02d81352b14b007068aa534968bc4 Mon Sep 17 00:00:00 2001 From: maier Date: Wed, 6 Oct 2021 10:41:26 -0400 Subject: [PATCH 1/3] fix: lowercase config err msgs fix: test tcp port for agent config --- internal/config/config.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/config/config.go b/internal/config/config.go index e7d1ee9..a217b15 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -226,6 +226,10 @@ func destConf() error { return fmt.Errorf("destination %s, port %s: %w", dest, addr, err) } + if err := testPort("tcp", a.String()); err != nil { + return fmt.Errorf("destination %s, port %s: %w", dest, addr, err) + } + viper.Set(KeyDestAgentURL, fmt.Sprintf("http://%s/write/%s", a.String(), id)) default: @@ -272,7 +276,7 @@ func apiConf() error { return fmt.Errorf("invalid API URL: %w", err) } if parsedURL.Scheme == "" || parsedURL.Host == "" || parsedURL.Path == "" { - return fmt.Errorf("Invalid API URL (%s)", apiURL) + return fmt.Errorf("invalid API URL (%s)", apiURL) } } From ddf48cf0a588ec833e39774563687637a78e3658 Mon Sep 17 00:00:00 2001 From: maier Date: Wed, 6 Oct 2021 10:41:41 -0400 Subject: [PATCH 2/3] fix: config unit tests --- internal/config/config_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 9d2f153..dbc725f 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -196,7 +196,7 @@ func TestLogConfDir(t *testing.T) { t.Log("no directory") { viper.Set(KeyLogConfDir, "") - expectedError := errors.New("Invalid log configuration directory ()") + expectedError := errors.New("invalid log configuration directory ()") err := logConfDir() if err == nil { t.Fatalf("Expected error") @@ -302,7 +302,7 @@ func TestApiConf(t *testing.T) { if err == nil { t.Fatal("Expected error") } - pfx := "Unable to access cosi config:" + pfx := "unable to access cosi config:" if !strings.HasPrefix(err.Error(), pfx) { t.Errorf("Expected (^%s) got (%s)", pfx, err) } @@ -340,7 +340,7 @@ func TestApiConf(t *testing.T) { viper.Set(KeyAPITokenKey, "foo") viper.Set(KeyAPITokenApp, "foo") viper.Set(KeyAPIURL, "foo") - expectedError := errors.New("Invalid API URL (foo)") + expectedError := errors.New("invalid API URL (foo)") err := apiConf() if err == nil { t.Fatal("Expected error") @@ -355,7 +355,7 @@ func TestApiConf(t *testing.T) { viper.Set(KeyAPITokenKey, "foo") viper.Set(KeyAPITokenApp, "foo") viper.Set(KeyAPIURL, "foo_bar://herp/derp") - expectedError := errors.New(`Invalid API URL: parse "foo_bar://herp/derp": first path segment in URL cannot contain colon`) + expectedError := errors.New(`invalid API URL: parse "foo_bar://herp/derp": first path segment in URL cannot contain colon`) err := apiConf() if err == nil { t.Fatal("Expected error") @@ -447,7 +447,7 @@ func TestLoadCosiConfig(t *testing.T) { zerolog.SetGlobalLevel(zerolog.Disabled) t.Log("cosi - missing") { - expectedError := errors.New("Unable to access cosi config: open testdata/cosi_missing.json: no such file or directory") + expectedError := errors.New("unable to access cosi config: open testdata/cosi_missing.json: no such file or directory") cosiCfgFile = filepath.Join("testdata", "cosi_missing.json") t.Logf("cosiCfgFile %s", cosiCfgFile) key, app, apiURL, err := loadCOSIConfig() From 54fbcd5a224ee52184a2a0d5b78e04e0055bf68e Mon Sep 17 00:00:00 2001 From: maier Date: Wed, 6 Oct 2021 10:41:52 -0400 Subject: [PATCH 3/3] v1.0.2 --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bdf928..7943965 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.0.2 + +* fix: config unit tests +* fix: test tcp port for agent config +* fix: lowercase config err msgs + # v1.0.1 * fix: lint issues