ducky/devices

Paddy 2015-11-27 Parent:f5a9d5f8f28d

11:683050b4546b Go to Latest

ducky/devices/memstore_test.go

Return ErrDeviceNotFound when updating devices. If we can't find the Device we're supposed to update, return an ErrDeviceNotFound error. Write a unit test that tests for this behaviour.

History
paddy@4 1 package devices
paddy@4 2
paddy@9 3 import (
paddy@9 4 "fmt"
paddy@9 5
paddy@9 6 "golang.org/x/net/context"
paddy@9 7 )
paddy@9 8
paddy@4 9 func init() {
paddy@9 10 storerFactories = append(storerFactories, MemstoreFactory{})
paddy@4 11 }
paddy@9 12
paddy@9 13 type MemstoreFactory struct {
paddy@9 14 }
paddy@9 15
paddy@9 16 func (m MemstoreFactory) NewStorer(ctx context.Context) (Storer, error) {
paddy@9 17 return NewMemstore(), nil
paddy@9 18 }
paddy@9 19
paddy@9 20 func (m MemstoreFactory) TeardownStorer(storer Storer, ctx context.Context) error {
paddy@9 21 memstorer, ok := storer.(*Memstore)
paddy@9 22 if !ok {
paddy@9 23 return fmt.Errorf("Storer was not a *Memstore, was a %T", storer)
paddy@9 24 }
paddy@9 25 memstorer.devices = nil
paddy@9 26 return nil
paddy@9 27 }