Skip to content

Commit 66d9882

Browse files
author
Divjot Arora
committed
GODRIVER-1893 Cleanup comments and tests
1 parent b88bb74 commit 66d9882

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

bson/primitive/objectid.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,10 @@ func ObjectIDFromHex(s string) (ObjectID, error) {
8888
return oid, nil
8989
}
9090

91-
// IsValidObjectID judges given string format is valid or invalid for ObjectID.
91+
// IsValidObjectID returns true if the provided hex string represents a valid ObjectID and false if not.
9292
func IsValidObjectID(s string) bool {
9393
_, err := ObjectIDFromHex(s)
94-
if err != nil {
95-
return false
96-
}
97-
98-
return true
94+
return err == nil
9995
}
10096

10197
// MarshalJSON returns the ObjectID as a string

bson/primitive/objectid_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func TestIsValidObjectID(t *testing.T) {
6363

6464
for _, testcase := range testCases {
6565
got := IsValidObjectID(testcase.givenID)
66-
require.Equal(t, testcase.expected, got)
66+
assert.Equal(t, testcase.expected, got, "expected hex string to be valid ObjectID: %v, got %v", testcase.expected, got)
6767
}
6868
}
6969

0 commit comments

Comments
 (0)