package store import ( "fmt" "gitea.deepak.science/deepak/gogmagog/models" ) func (e *errorStore) SelectActions(userID int) ([]*models.Action, error) { return nil, e.error } func (e *errorStore) SelectActionByID(id int, userID int) (*models.Action, error) { return nil, e.error } func (e *errorStore) InsertAction(action *models.Action, userID int) (int, error) { if e.errorOnInsert { return 0, e.error } return 0, nil } func (e *errorStore) UpdateAction(action *models.Action, userID int) error { if e.errorOnInsert { return e.error } return nil } func (e *errorStore) SelectPlans(userID int) ([]*models.Plan, error) { return nil, e.error } func (e *errorStore) SelectPlanByID(id int, userID int) (*models.Plan, error) { return nil, e.error } func (e *errorStore) InsertPlan(plan *models.Plan, userID int) (int, error) { if e.errorOnInsert { return 0, e.error } return 0, nil } func (e *errorStore) UpdatePlan(plan *models.Plan, userID int) error { if e.errorOnInsert { return e.error } return nil } func (e *errorStore) SelectActionsByPlanID(plan *models.Plan, userID int) ([]*models.Action, error) { return nil, e.error } func (e *errorStore) SelectUserByUsername(name string) (*models.User, error) { return nil, e.error } func (e *errorStore) InsertUser(user *models.User) (int, error) { if e.errorOnInsert { return 0, e.error } return 0, nil } func (e *errorStore) SelectCurrentPlan(userID int) (*models.CurrentPlan, error) { return nil, e.error } func (e *errorStore) InsertCurrentPlan(currentPlan *models.CurrentPlan, userID int) error { if e.errorOnInsert { return e.error } return nil } func (e *errorStore) UpdateCurrentPlan(currentPlan *models.CurrentPlan, userID int) error { if e.errorOnInsert { return e.error } return nil } func (e *errorStore) ConnectionLive() error { return e.error } type errorStore struct { error error errorOnInsert bool } // GetErrorStore returns a models.Store that always errors. This is useful for testing purposes. func GetErrorStore(errorMsg string, errorOnInsert bool) models.Store { e := &errorStore{error: fmt.Errorf(errorMsg), errorOnInsert: errorOnInsert} return e } // GetErrorStoreForError returns a models.Store that always errors with the provided error. func GetErrorStoreForError(err error, errorOnInsert bool) models.Store { e := &errorStore{error: err, errorOnInsert: errorOnInsert} return e }