You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to propose a new API, take a look at this example:
import"testing"import mocket "github.com/selvatico/go-mocket"import"app/app/entity"funcTestDelete(t*testing.T) {
varexpectedIdint=1notification:= entity.Notification{}
notification.SetId(expectedId)
notificationService:=GetNotificationService()
definitions:=map[string]interface{}{
"type": "update",
"table": "notifications",
"set": map[string]interface{}{"deleted_at": mocket.Any},
"where": map[string]interface{}{"id": expectedId},
}
query:=mocket.NewQueryMock(definitions) // create the query mockmocket.WatchQuery(query) // start the watchernotificationService.Delete(¬ification) // Trigger query// assertion, it can be made of two ways// it can be:mocket.assertWasCalled(query, t) // assert it was called// or:ifmocket.assertWasCalled(query) ==false {
t.Fail()
}
}
I think this is more readable, and easy to write.
The text was updated successfully, but these errors were encountered:
I'd like to propose a new API, take a look at this example:
I think this is more readable, and easy to write.
The text was updated successfully, but these errors were encountered: