package benefactorkindboxreqmock import ( "context" "fmt" "time" "git.gocasts.ir/ebhomengo/niki/entity" ) const RepoErr = "record not found" 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 }