sqlmock is not matching query, but query is identical and log output shows the same

前端 未结 3 1893
南方客
南方客 2021-01-18 07:20

I\'m trying to write tests for some code using Gorm using sqlmock. I figured out writing tests for my insert function but now pulling my hair out trying to get an update wor

3条回答
  •  猫巷女王i
    2021-01-18 07:36

    Try this:

    mock.ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "storage_pools" WHERE "storage_pools"."deleted_at" IS NULL AND ((poolid = ?)) ORDER BY "storage_pools"."id" ASC LIMIT 1`))
    

    Put your query into this function regexp.QuoteMeta().

提交回复
热议问题