Unit tests
Closed this issue · 1 comments
marczahn commented
Hi,
I do not get an approach for it. I have this function:
func PlanById(ctx TransactionalCtx, id uint64) (*Plan, error) {
var plan Plan
err := ctx.GetTx().
Select("*").
From("plans").
Where("id = ?", id).
LoadStruct(&plan)
if err != nil {
return nil, ConvertError(err, "plan", ErrorField{"id", id})
}
return &plan, nil
}
How can I now "mock" (I know there is no mocking in Go) the transaction so that I can just test LoadStruct? Is it possible at all?
marczahn commented
Solved: I just found this package: https://github.com/DATA-DOG/go-sqlmock