func (m *Mock) Replace(id string, replaced Resource) (Resource, error) {
	if err := checkResourceKeyExists(m.data, m.key); err != nil {
		return nil, ErrResourceNotFound
	}
	if _, err := m.FindById(id); err != nil {
		return nil, err
	}
	replaced["id"] = id
	newResources := make([]Resource, 0)
	for _, d := range m.data[m.key] {
		if d["id"] == id {
			newResources = append(newResources, replaced)
		} else {
			newResources = append(newResources, d)
		}
	}
	m.data[m.key] = newResources
	return replaced, nil
}
Replace an existing mock resource for the specific key.
package storage
type Mock struct {
	data Database
	key  string
}
func NewMock(data Database, key string) (*Mock, error) {
	return &Mock{data: data, key: key}, nil
}
func (m *Mock) Find() ([]Resource, error) {
	return m.data[m.key], nil
}
func (m *Mock) FindById(id string) (Resource, error) {
	if err := checkResourceKeyExists(m.data, m.key); err != nil {
		return nil, ErrResourceNotFound
	}
	for _, resource := range m.data[m.key] {
		if resource["id"] == id {
			return resource, nil
		}
	}
	return nil, ErrResourceNotFound
}
func (m *Mock) Create(newResource Resource) (Resource, error) {
	if err := checkResourceKeyExists(m.data, m.key); err != nil {
		return nil, ErrResourceNotFound
	}
	_, ok := newResource["id"]
	if !ok {
		newResource["id"] = generateNewId(m.data[m.key])
	} else {
		for _, resource := range m.data[m.key] {
			if resource["id"] == newResource["id"] {
				return nil, ErrResourceAlreadyExists
			}
		}
	}
	newData := append(m.data[m.key], newResource)
	m.data[m.key] = newData
	return newResource, nil
}