github.com/mundipagg/boleto-api@v0.0.0-20230620145841-3f9ec742599f/db/mock.go (about) 1 package db 2 3 import ( 4 "errors" 5 6 "github.com/mundipagg/boleto-api/cache" 7 "github.com/mundipagg/boleto-api/models" 8 ) 9 10 //SaveBoleto salva o boleto num cache local em memoria 11 func SaveBoletoMock(boleto models.BoletoView) error { 12 idBson := boleto.ID.Hex() 13 cache.Set(idBson, boleto) 14 return nil 15 } 16 17 //GetBoletoById retorna o boleto por id do cache em memoria 18 func GetBoletoByIDMock(id string) (models.BoletoView, error) { 19 c, ok := cache.Get(string(id)) 20 if !ok { 21 return models.BoletoView{}, errors.New("Boleto não encontrado") 22 } 23 return c.(models.BoletoView), nil 24 } 25 26 func Close() {}