mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-13 22:15:42 +08:00
* Add commands index to command datastore. Add simple test for commands index Add commands index endpoint (cherry picked from commit 4e2a2a2) * Add handler for GET /mdm/commands (cherry picked from commit ae71b8f) * Added Find() method to commands datastore so that the request that matches a response can be retrieved by the connect service. Added Find() method to command service (cherry picked from commit ebceb28) * Fix globally scoped vars in command datastore test suite * groob prefers inline definition of struct members. * Uppercase CommandUuid
45 lines
784 B
Go
45 lines
784 B
Go
package command
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/go-kit/kit/log"
|
|
"github.com/micromdm/mdm"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
type datastoreFixtures struct {
|
|
ds Datastore
|
|
logger log.Logger
|
|
}
|
|
|
|
func setup() (datastoreFixtures, error) {
|
|
logger := log.NewLogfmtLogger(os.Stdout)
|
|
commandsDb, err := NewDB("redis", "localhost", logger)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return datastoreFixtures{ds: commandsDb, logger: logger}
|
|
}
|
|
|
|
func teardown() {
|
|
|
|
}
|
|
|
|
func TestService_Commands(t *testing.T) {
|
|
fixtures, err := setup()
|
|
defer teardown()
|
|
if err != nil {
|
|
t.Errorf("error making new datastore: %v", err)
|
|
}
|
|
|
|
var commands []mdm.Payload
|
|
commands, err = fixtures.ds.Commands("ABCDEF")
|
|
if err != nil {
|
|
t.Errorf("datastore.Commands returned error: %v", err)
|
|
}
|
|
|
|
fmt.Printf("%v", commands)
|
|
}
|