Added plan by id route and error handling and organisation

This commit is contained in:
2021-01-01 08:41:17 -06:00
parent bbb0cf3f42
commit 95d945dda7
6 changed files with 162 additions and 9 deletions

View File

@@ -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
}