forked from domodwyer/mgo
-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't panic on indexed int64 fields (#23)
* Stop all db instances after tests (go-mgo#462) If all tests pass, the builds for mongo earlier than 2.6 are still failing. Running a clean up fixes the issue. * fixing int64 type failing when getting indexes and trying to type them * requested changes relating to case statement and panic * Update README.md to credit @mapete94. * tests: ensure indexed int64 fields do not cause a panic in Indexes() See: * #23 * https://github.com/go-mgo/mgo/issues/475 * go-mgo#476
- Loading branch information
Showing
3 changed files
with
42 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package mgo | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/globalsign/mgo/bson" | ||
) | ||
|
||
// This file is for testing functions that are not exported outside the mgo | ||
// package - avoid doing so if at all possible. | ||
|
||
// Ensures indexed int64 fields do not cause mgo to panic. | ||
// | ||
// See https://github.com/globalsign/mgo/pull/23 | ||
func TestIndexedInt64FieldsBug(t *testing.T) { | ||
input := bson.D{ | ||
{Name: "testkey", Value: int(1)}, | ||
{Name: "testkey", Value: int64(1)}, | ||
{Name: "testkey", Value: "test"}, | ||
{Name: "testkey", Value: float64(1)}, | ||
} | ||
|
||
_ = simpleIndexKey(input) | ||
} |