Skip to content

Commit

Permalink
Use the root package for shared errors #minor
Browse files Browse the repository at this point in the history
* Use the root package for shared errors

* add back mock

* remove merge derp

* remove merge derp
  • Loading branch information
sjauld authored Feb 8, 2020
1 parent ea5c60a commit 788b3fc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion dynamodb/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dynamodb
import (
"fmt"

"github.com/ace-teknologi/memzy"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/dynamodb"
Expand Down Expand Up @@ -46,7 +47,7 @@ func (c *Client) GetItem(v interface{}, key map[string]interface{}) error {
}

if out.Item == nil {
return ErrNotFound
return memzy.ErrNotFound
}

err = dynamodbattribute.UnmarshalMap(out.Item, v)
Expand Down
2 changes: 1 addition & 1 deletion dynamodb/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func TestGetMissingItem(t *testing.T) {
obj := &MegaTest{}

err := c.GetItem(obj, map[string]interface{}{"MegaString": "missing"})
if err == nil || err != ErrNotFound {
if err == nil || err != memzy.ErrNotFound {
t.Errorf("Expected ErrNotFound, got %v", err)
}
}
Expand Down
7 changes: 7 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package memzy


import "fmt"

// ErrNotFound is returned if you try to get an item that doesn't exist
var ErrNotFound = fmt.Errorf("Item not found")
4 changes: 3 additions & 1 deletion memory/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package memory
import (
"encoding/json"
"fmt"

"github.com/ace-teknologi/memzy"
)

// Store provides a key-value store in memory.
Expand Down Expand Up @@ -42,7 +44,7 @@ func (s *Store) GetItem(v interface{}, key map[string]interface{}) error {
}

if len(bytes) == 0 {
return fmt.Errorf("Could not find %v in memory", keyStr)
return memzy.ErrNotFound
}

return json.Unmarshal(bytes, v)
Expand Down

0 comments on commit 788b3fc

Please sign in to comment.