Added plan by id route and error handling and organisation
This commit is contained in:
@@ -10,11 +10,23 @@ type multiStore struct {
|
||||
plans []*models.Plan
|
||||
}
|
||||
|
||||
type testNotFoundError struct {
|
||||
error
|
||||
}
|
||||
|
||||
func (t *testNotFoundError) NotFound() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (ms *multiStore) SelectActions() ([]*models.Action, error) {
|
||||
return ms.actions, nil
|
||||
}
|
||||
|
||||
func (ms *multiStore) SelectActionByID(id int) (*models.Action, error) {
|
||||
if len(ms.actions) < 1 {
|
||||
err := &testNotFoundError{fmt.Errorf("too small")}
|
||||
return nil, err
|
||||
}
|
||||
return ms.actions[0], nil
|
||||
}
|
||||
|
||||
@@ -23,6 +35,10 @@ func (ms *multiStore) SelectPlans() ([]*models.Plan, error) {
|
||||
}
|
||||
|
||||
func (ms *multiStore) SelectPlanByID(id int) (*models.Plan, error) {
|
||||
if len(ms.plans) < 1 {
|
||||
err := &testNotFoundError{fmt.Errorf("too small")}
|
||||
return nil, err
|
||||
}
|
||||
return ms.plans[0], nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user