skip to content
Alvin Lucillo

MongoDB mocked error response

/ 1 min read

💻 Tech

Yesterday, I posted about mocking query transactions like FindOne. Today, I’ll share how to mock an error.

errorCode := 1001
errorMessage := "internal error"

mtest.CreateWriteErrorsResponse(mtest.WriteError{
    Index:   0,
    Code:    errorCode,
    Message: errorMessage,
}),