Skip to content

Commit

Permalink
Fix integer constant overflows in tests (#4616)
Browse files Browse the repository at this point in the history
* Use integer limit value [1] instead of hard-coded magic constant for
  NonexistentID.

* Explicitly use int64 in order to avoid the following errors on 32 bit
  architectures:

  # code.gitea.io/gitea/integrations
  ./api_admin_test.go:50:34: constant 9223372036854775807 overflows int
  ./api_token_test.go:47:34: constant 9223372036854775807 overflows int
  [...]
  # code.gitea.io/gitea/models
  ./action_test.go:179:15: constant 9223372036854775807 overflows int

[1] https://golang.org/pkg/math/#pkg-constants

Signed-off-by: Dennis Menschel <[email protected]>
  • Loading branch information
menschel-d authored and lafriks committed Aug 6, 2018
1 parent 9ea327f commit 9c0a374
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion models/unit_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package models
import (
"fmt"
"io/ioutil"
"math"
"net/url"
"os"
"path/filepath"
Expand All @@ -23,7 +24,7 @@ import (
)

// NonexistentID an ID that will never exist
const NonexistentID = 9223372036854775807
const NonexistentID = int64(math.MaxInt64)

// giteaRoot a path to the gitea root
var giteaRoot string
Expand Down

0 comments on commit 9c0a374

Please sign in to comment.