Avoid 500 response for empty command queue (#135)

* Avoid 500 response for empty command queue
This commit is contained in:
Jesse Peterson
2017-03-31 10:55:39 -07:00
committed by GitHub
parent ea5dab77bd
commit 90ab393742
2 changed files with 5 additions and 2 deletions

View File

@@ -27,6 +27,9 @@ type Store struct {
func (db *Store) Next(ctx context.Context, resp mdm.Response) (*Command, error) {
dc, err := db.DeviceCommand(resp.UDID)
if err != nil {
if isNotFound(err) {
return nil, nil
}
return nil, errors.Wrapf(err, "get device command from queue, udid: %s", resp.UDID)
}

View File

@@ -136,8 +136,8 @@ func TestNext_zeroCommands(t *testing.T) {
t.Run(s, func(t *testing.T) {
resp := mdm.Response{CommandUUID: s, Status: s}
cmd, err := store.Next(ctx, resp)
if err == nil {
t.Error("expected err but got nil")
if err != nil {
t.Errorf("expected nil, but got err: %s", err)
}
if cmd != nil {
t.Errorf("expected nil cmd but got %s", cmd.UUID)