diff --git a/CHANGELOG.md b/CHANGELOG.md index 74c6ea4c..c5af3e6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 7.0.0 +* `geoipupdate` now supports retrying on more types of errors + such as HTTP2 INTERNAL_ERROR. * `HTTPReader` no longer retries on HTTP errors and therefore `retryFor` was removed from `NewHTTPReader`. diff --git a/pkg/geoipupdate/config.go b/pkg/geoipupdate/config.go index ff0379d4..5655ab4b 100644 --- a/pkg/geoipupdate/config.go +++ b/pkg/geoipupdate/config.go @@ -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{}{} @@ -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") } } @@ -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") } } @@ -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 diff --git a/pkg/geoipupdate/internal/job_processor_test.go b/pkg/geoipupdate/internal/job_processor_test.go index cc9f2bd4..0b4dad35 100644 --- a/pkg/geoipupdate/internal/job_processor_test.go +++ b/pkg/geoipupdate/internal/job_processor_test.go @@ -2,6 +2,7 @@ package internal import ( "context" + "strings" "sync" "testing" "time" @@ -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) }() @@ -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) }()