32 lines
822 B
Go
32 lines
822 B
Go
package testenv
|
|
|
|
import (
|
|
"src.dualinventive.com/go/cp3000-interface/internal/storage"
|
|
)
|
|
|
|
// RAMRepository contains functions for unit testing. It stores the data in RAM
|
|
type RAMRepository struct {
|
|
Devices map[string]*storage.Device
|
|
}
|
|
|
|
// NewRAMRepository returns a repository for unit testing
|
|
func NewRAMRepository() *RAMRepository {
|
|
return &RAMRepository{
|
|
Devices: make(map[string]*storage.Device),
|
|
}
|
|
}
|
|
|
|
// GetDeviceByIMEI returns a device by its IMEI
|
|
func (f *RAMRepository) GetDeviceByIMEI(imei string) (*storage.Device, error) {
|
|
d, found := f.Devices[imei]
|
|
if !found {
|
|
return nil, storage.ErrNotFound
|
|
}
|
|
return d, nil
|
|
}
|
|
|
|
// GetDeviceByDeviceUID returns a device by it's device UID
|
|
func (f *RAMRepository) GetDeviceByDeviceUID(deviceUID string) (*storage.Device, error) {
|
|
return nil, storage.ErrNotFound
|
|
}
|