package main import ( "testing" intdevice "netdome.biz/paul/qmk-rgb/internal/device" "netdome.biz/paul/qmk-rgb/internal/via" ) // stubOpenTarget points the commands at one protocol, the display names a board // would supply and the channels that board has. It returns the restore function. func stubOpenTarget(t *testing.T, proto rgbProtocol, display map[uint16]string, channels []via.Channel, vendorID, productID uint16) func() { t.Helper() original := openTarget openTarget = func() (rgbProtocol, targetDeviceData, []via.Channel, error) { target := targetDeviceData{ Device: intdevice.Device{VendorID: vendorID, ProductID: productID}, Display: display, } requested, err := resolveZoneName(targetZone, display) if err != nil { return nil, target, nil, err } target.Requested = requested resolved, err := resolveChannels(proto, target) if err != nil { return nil, target, nil, err } return proto, target, resolved, nil } return func() { openTarget = original } } // impact80Target is the board most command tests describe. func impact80Target(t *testing.T, proto rgbProtocol) func() { t.Helper() return stubOpenTarget(t, proto, impact80Display(), impact80Channels(), 0x36B0, 0x309F) }