func retrieve(t *testing.T, q QueueInterfaces, r *mdm.Request, cmdStr string, skipNotNow bool) {
	retCmd, err := q.RetrieveNextCommand(r, skipNotNow)
	if err != nil {
		t.Fatal(err)
	}
	compareCommand(t, cmdStr, retCmd)
}
retrieve retrieves the next command from the backend
package test
import (
	"context"
	"testing"
	"github.com/groob/plist"
	"github.com/micromdm/nanomdm/mdm"
	"github.com/micromdm/nanomdm/storage"
)
type QueueInterfaces interface {
	storage.CommandEnqueuer
	storage.CommandAndReportResultsStore
}
func newCommand(cmd string) (*mdm.Command, error) {
	fCmd := &struct {
		CommandUUID string
		Command     struct {
			RequestType string
		}
	}{
		CommandUUID: cmd,
		Command:     struct{ RequestType string }{cmd},
	}
	rawBytes, err := plist.Marshal(fCmd)
	if err != nil {
		return nil, err
	}
	return &mdm.Command{
		CommandUUID: fCmd.CommandUUID,
		Command:     fCmd.Command,
		Raw:         rawBytes,
	}, nil
}
func enqueue(t *testing.T, q QueueInterfaces, ctx context.Context, id, cmdStr string) {
	cmd, err := newCommand(cmdStr)
	if err != nil {
		t.Fatal(err)
	}
	res, err := q.EnqueueCommand(ctx, []string{id}, cmd)
	if err != nil {
		t.Fatal(err)
	}
	for k, v := range res {
		t.Fatalf("enqueuing to ID %s: %v", k, v)
	}
}
func compareCommand(t *testing.T, cmdStr string, cmd *mdm.Command) {
	if cmdStr != "" && cmd == nil {
		t.Errorf("expected next command, but got empty response. wanted: %q", cmdStr)
		return
	}
	if cmdStr == "" && cmd != nil {
		t.Errorf("expected empty next command, but got: %q", cmd.CommandUUID)
	}
	if cmd == nil {
		return
	}
	if cmd.CommandUUID != cmdStr {
		t.Errorf("mismatched command UUID. want: %q, have: %q", cmdStr, cmd.CommandUUID)
	}
	if cmd.Command.RequestType != cmdStr {
		t.Errorf("mismatched command RequestType. want: %q, have: %q", cmdStr, cmd.Command.RequestType)
	}
}