Skip to content

Commit

Permalink
GODRIVER-1893 Cleanup comments and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Divjot Arora committed Mar 2, 2021
1 parent b88bb74 commit 66d9882
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions bson/primitive/objectid.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,10 @@ func ObjectIDFromHex(s string) (ObjectID, error) {
return oid, nil
}

// IsValidObjectID judges given string format is valid or invalid for ObjectID.
// IsValidObjectID returns true if the provided hex string represents a valid ObjectID and false if not.
func IsValidObjectID(s string) bool {
_, err := ObjectIDFromHex(s)
if err != nil {
return false
}

return true
return err == nil
}

// MarshalJSON returns the ObjectID as a string
Expand Down
2 changes: 1 addition & 1 deletion bson/primitive/objectid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestIsValidObjectID(t *testing.T) {

for _, testcase := range testCases {
got := IsValidObjectID(testcase.givenID)
require.Equal(t, testcase.expected, got)
assert.Equal(t, testcase.expected, got, "expected hex string to be valid ObjectID: %v, got %v", testcase.expected, got)
}
}

Expand Down

0 comments on commit 66d9882

Please sign in to comment.