2024-01-26 12:11:50 +00:00
|
|
|
package benefactorkindboxreqmock
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"git.gocasts.ir/ebhomengo/niki/entity"
|
|
|
|
)
|
|
|
|
|
2024-04-26 19:30:35 +00:00
|
|
|
const RepoErr = "record not found"
|
2024-01-26 12:11:50 +00:00
|
|
|
|
|
|
|
type DefaultKindBoxReqTest struct {
|
|
|
|
BenefactorID uint
|
|
|
|
TypeID entity.KindBoxType
|
|
|
|
AddressID uint
|
|
|
|
ReferDate time.Time
|
|
|
|
CountRequested uint
|
|
|
|
}
|
|
|
|
|
|
|
|
func DefaultKindBoxReq() DefaultKindBoxReqTest {
|
|
|
|
return DefaultKindBoxReqTest{
|
|
|
|
BenefactorID: 1,
|
|
|
|
TypeID: 1,
|
|
|
|
AddressID: 1,
|
|
|
|
ReferDate: time.Now(),
|
|
|
|
CountRequested: 1,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type MockRepository struct {
|
|
|
|
kindBoxReqs []entity.KindBoxReq
|
|
|
|
hasErr bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewMockRepository(hasErr bool) *MockRepository {
|
|
|
|
var kindBoxReqs []entity.KindBoxReq
|
|
|
|
DefaultKindBoxReq := DefaultKindBoxReq()
|
|
|
|
|
|
|
|
kindBoxReqs = append(kindBoxReqs, entity.KindBoxReq{
|
|
|
|
BenefactorID: DefaultKindBoxReq.BenefactorID,
|
|
|
|
AddressID: DefaultKindBoxReq.AddressID,
|
|
|
|
KindBoxType: DefaultKindBoxReq.TypeID,
|
|
|
|
ReferDate: DefaultKindBoxReq.ReferDate,
|
|
|
|
CountRequested: DefaultKindBoxReq.CountRequested,
|
|
|
|
Status: entity.KindBoxReqPendingStatus,
|
|
|
|
})
|
|
|
|
|
|
|
|
return &MockRepository{
|
|
|
|
kindBoxReqs: kindBoxReqs,
|
|
|
|
hasErr: hasErr,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//nolint
|
|
|
|
func (m *MockRepository) AddKindBoxReq(ctx context.Context, kindBoxReq entity.KindBoxReq) (entity.KindBoxReq, error) {
|
|
|
|
if m.hasErr {
|
|
|
|
return entity.KindBoxReq{}, fmt.Errorf(RepoErr)
|
|
|
|
}
|
|
|
|
|
|
|
|
kindBoxReq.ID = 1
|
|
|
|
m.kindBoxReqs = append(m.kindBoxReqs, kindBoxReq)
|
|
|
|
|
|
|
|
return kindBoxReq, nil
|
|
|
|
}
|