Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions internal/repository/memory.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package repository

import (
"errors"
"fmt"
"sync"
"time"

"github.com/wise/backend-interview-kit/internal/model"
)

var ErrNotFound = errors.New("item not found")

type memoryRepository struct {
mu sync.RWMutex
jobs map[string]*model.Job
Expand Down Expand Up @@ -134,7 +137,7 @@ func (r *memoryRepository) GetJob(id string) (*model.Job, error) {

job, ok := r.jobs[id]
if !ok {
return nil, nil
return nil, ErrNotFound
}
return job, nil
}
Expand Down Expand Up @@ -175,7 +178,7 @@ func (r *memoryRepository) GetDriver(id string) (*model.Driver, error) {

driver, ok := r.drivers[id]
if !ok {
return nil, nil
return nil, ErrNotFound
}
return driver, nil
}
Expand All @@ -197,7 +200,7 @@ func (r *memoryRepository) GetDepot(id string) (*model.Depot, error) {

depot, ok := r.depots[id]
if !ok {
return nil, nil
return nil, ErrNotFound
}
return depot, nil
}