mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-12 04:55:39 +08:00
Avoid 500 response for empty command queue (#135)
* Avoid 500 response for empty command queue
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user