Skip to content

Commit

Permalink
Merge pull request #24 from maier/master
Browse files Browse the repository at this point in the history
v1.0.2
  • Loading branch information
maier committed Oct 6, 2021
2 parents 31e94cd + 54fbcd5 commit 9133aaf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 5 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
}
}

Expand Down
10 changes: 5 additions & 5 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 9133aaf

Please sign in to comment.