Skip to content

Commit

Permalink
Fix linters
Browse files Browse the repository at this point in the history
  • Loading branch information
marselester committed Feb 7, 2024
1 parent 00b021f commit 5fb9587
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
12 changes: 6 additions & 6 deletions pkg/geoipupdate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func setConfigFromFile(config *Config, path string) error {
case "AccountID", "UserId":
accountID, err := strconv.Atoi(value)
if err != nil {
return fmt.Errorf("invalid account ID format")
return errors.New("invalid account ID format")
}
config.AccountID = accountID
keysSeen["AccountID"] = struct{}{}
Expand Down Expand Up @@ -286,7 +286,7 @@ func setConfigFromEnv(config *Config) error {
var err error
config.AccountID, err = strconv.Atoi(value)
if err != nil {
return fmt.Errorf("invalid account ID format")
return errors.New("invalid account ID format")
}
}

Expand All @@ -300,7 +300,7 @@ func setConfigFromEnv(config *Config) error {

config.AccountID, err = strconv.Atoi(strings.TrimSpace(string(accountID)))
if err != nil {
return fmt.Errorf("invalid account ID format")
return errors.New("invalid account ID format")
}
}

Expand Down Expand Up @@ -396,15 +396,15 @@ func validateConfig(config *Config) error {
}

if len(config.EditionIDs) == 0 {
return fmt.Errorf("the `EditionIDs` option is required")
return errors.New("the `EditionIDs` option is required")
}

if config.AccountID == 0 {
return fmt.Errorf("the `AccountID` option is required")
return errors.New("the `AccountID` option is required")
}

if config.LicenseKey == "" {
return fmt.Errorf("the `LicenseKey` option is required")
return errors.New("the `LicenseKey` option is required")
}

return nil
Expand Down
13 changes: 10 additions & 3 deletions pkg/geoipupdate/internal/job_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package internal

import (
"context"
"strings"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -61,8 +62,9 @@ func TestJobQueueRun(t *testing.T) {
// Execute run in a goroutine so that we can exit early if the test
// hangs or takes too long to execute.
go func() {
err := jobProcessor.Run(ctx)
require.NoError(t, err)
if err := jobProcessor.Run(ctx); err != nil {
t.Error(err)
}
close(doneCh)
}()

Expand Down Expand Up @@ -106,7 +108,12 @@ func TestJobQueueStop(t *testing.T) {
// hangs or takes too long to execute.
go func() {
err := jobProcessor.Run(ctx)
require.ErrorContains(t, err, "processing cancelled")
if err == nil {
t.Error(`expected "processing cancelled" error`)
}
if !strings.Contains(err.Error(), "processing cancelled") {
t.Errorf(`expected "processing cancelled" error, got %q`, err)
}
close(doneCh)
}()

Expand Down

0 comments on commit 5fb9587

Please sign in to comment.