Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qingyang-hu committed Mar 5, 2025
1 parent 0142746 commit beb9ad2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/integration/client_side_encryption_prose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func TestClientSideEncryptionProse(t *testing.T) {
assert.True(mt, strings.Contains(insertErr.Error(), "auth error"),
"expected InsertOne auth error, got %v", insertErr)
assert.True(mt, strings.Contains(encErr.Error(), "auth error"),
"expected Encrypt auth error, got %v", insertErr)
"expected Encrypt auth error, got %v", encErr)
return
}
assert.Nil(mt, insertErr, "InsertOne error: %v", insertErr)
Expand Down
8 changes: 4 additions & 4 deletions mongo/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func replaceErrors(err error) error {
if errors.Is(err, topology.ErrTopologyClosed) {
return ErrClientDisconnected
}
if de := new(driver.Error); errors.As(err, de) {
if de, ok := err.(driver.Error); ok {
return CommandError{
Code: de.Code,
Message: de.Message,
Expand All @@ -74,7 +74,7 @@ func replaceErrors(err error) error {
Raw: bson.Raw(de.Raw),
}
}
if qe := new(driver.QueryFailureError); errors.As(err, qe) {
if qe, ok := err.(driver.QueryFailureError); ok {
// qe.Message is "command failure"
ce := CommandError{
Name: qe.Message,
Expand All @@ -93,15 +93,15 @@ func replaceErrors(err error) error {

return ce
}
if me := new(mongocrypt.Error); errors.As(err, me) {
if me, ok := err.(mongocrypt.Error); ok {
return MongocryptError{Code: me.Code, Message: me.Message}
}

if errors.Is(err, codecutil.ErrNilValue) {
return ErrNilValue
}

if marshalErr := new(codecutil.MarshalError); errors.As(err, marshalErr) {
if marshalErr, ok := err.(codecutil.MarshalError); ok {
return MarshalError{
Value: marshalErr.Value,
Err: marshalErr.Err,
Expand Down

0 comments on commit beb9ad2

Please sign in to comment.