mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-27 05:15:47 +00:00
add convenience method to pull params from config
This commit is contained in:
@@ -199,7 +199,7 @@ func TestBadArtnetPacketFilter(t *testing.T) {
|
||||
Type: 0,
|
||||
},
|
||||
params: map[string]any{},
|
||||
errorString: "artnet.packet.filter requires an opCode parameter",
|
||||
errorString: "artnet.packet.filter opCode error: not found",
|
||||
},
|
||||
{
|
||||
name: "opCode not a number",
|
||||
@@ -217,7 +217,7 @@ func TestBadArtnetPacketFilter(t *testing.T) {
|
||||
Type: 0,
|
||||
},
|
||||
params: map[string]any{"opCode": "100"},
|
||||
errorString: "artnet.packet.filter opCode must be a number",
|
||||
errorString: "artnet.packet.filter opCode error: not a number",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -133,25 +133,25 @@ func TestBadIntRandom(t *testing.T) {
|
||||
name: "no min param",
|
||||
payload: "hello",
|
||||
params: map[string]any{"max": 10.0},
|
||||
errorString: "int.random requires a min parameter",
|
||||
errorString: "int.random min error: not found",
|
||||
},
|
||||
{
|
||||
name: "no max param",
|
||||
payload: "hello",
|
||||
params: map[string]any{"min": 1.0},
|
||||
errorString: "int.random requires a max parameter",
|
||||
errorString: "int.random max error: not found",
|
||||
},
|
||||
{
|
||||
name: "min param not a number",
|
||||
payload: "hello",
|
||||
params: map[string]any{"min": "1", "max": 10.0},
|
||||
errorString: "int.random min must be a number",
|
||||
errorString: "int.random min error: not a number",
|
||||
},
|
||||
{
|
||||
name: "max param not a number",
|
||||
payload: "hello",
|
||||
params: map[string]any{"min": 1.0, "max": "10"},
|
||||
errorString: "int.random max must be a number",
|
||||
errorString: "int.random max error: not a number",
|
||||
},
|
||||
{
|
||||
name: "max less than min",
|
||||
|
||||
@@ -104,7 +104,7 @@ func TestBadMIDIMessageFilter(t *testing.T) {
|
||||
name: "no type param",
|
||||
params: map[string]any{},
|
||||
payload: midi.NoteOn(1, 60, 127),
|
||||
errorString: "midi.message.filter requires a type parameter",
|
||||
errorString: "midi.message.filter type error: not found",
|
||||
},
|
||||
{
|
||||
name: "non-string type param",
|
||||
@@ -112,7 +112,7 @@ func TestBadMIDIMessageFilter(t *testing.T) {
|
||||
"type": 123,
|
||||
},
|
||||
payload: "hello",
|
||||
errorString: "midi.message.filter type must be a string",
|
||||
errorString: "midi.message.filter type error: not a string",
|
||||
},
|
||||
{
|
||||
name: "non-midi message input",
|
||||
|
||||
@@ -185,7 +185,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "no address parameter",
|
||||
params: map[string]any{},
|
||||
payload: "test",
|
||||
errorString: "osc.message.create requires an address parameter",
|
||||
errorString: "osc.message.create address error: not found",
|
||||
},
|
||||
{
|
||||
name: "non-string address parameter",
|
||||
@@ -193,7 +193,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
"address": 123,
|
||||
},
|
||||
payload: "test",
|
||||
errorString: "osc.message.create address must be a string",
|
||||
errorString: "osc.message.create address error: not a string",
|
||||
},
|
||||
{
|
||||
name: "bad address template",
|
||||
@@ -220,7 +220,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
"args": []interface{}{"arg1"},
|
||||
},
|
||||
payload: "test",
|
||||
errorString: "osc.message.create requires a types parameter with args",
|
||||
errorString: "osc.message.create types error: not found",
|
||||
},
|
||||
{
|
||||
name: "args and types length mismatch",
|
||||
@@ -240,7 +240,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
"types": "ss",
|
||||
},
|
||||
payload: "test",
|
||||
errorString: "osc.message.create arg must be a string",
|
||||
errorString: "osc.message.create arg error: not a string",
|
||||
},
|
||||
{
|
||||
name: "bad arg template",
|
||||
@@ -260,7 +260,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
"types": 123,
|
||||
},
|
||||
payload: "test",
|
||||
errorString: "osc.message.create types must be a string",
|
||||
errorString: "osc.message.create types error: not a string",
|
||||
},
|
||||
{
|
||||
name: "invalid type in types parameter",
|
||||
|
||||
@@ -108,7 +108,7 @@ func TestBadOSCMessageFilter(t *testing.T) {
|
||||
name: "no address parameter",
|
||||
params: map[string]any{},
|
||||
payload: osc.OSCMessage{Address: "/test"},
|
||||
errorString: "osc.message.filter requires an address parameter",
|
||||
errorString: "osc.message.filter address error: not found",
|
||||
},
|
||||
{
|
||||
name: "non-string address parameter",
|
||||
@@ -116,7 +116,7 @@ func TestBadOSCMessageFilter(t *testing.T) {
|
||||
"address": 123,
|
||||
},
|
||||
payload: osc.OSCMessage{Address: "/test"},
|
||||
errorString: "osc.message.filter address must be a string",
|
||||
errorString: "osc.message.filter address error: not a string",
|
||||
},
|
||||
{
|
||||
name: "bad address pattern",
|
||||
|
||||
@@ -103,7 +103,7 @@ func TestBadScriptWASM(t *testing.T) {
|
||||
name: "no path parameter",
|
||||
params: map[string]any{},
|
||||
payload: []byte("hello"),
|
||||
errorString: "script.wasm requires a path parameter",
|
||||
errorString: "script.wasm path error: not found",
|
||||
},
|
||||
{
|
||||
name: "non-string path parameter",
|
||||
@@ -111,7 +111,7 @@ func TestBadScriptWASM(t *testing.T) {
|
||||
"path": 12345,
|
||||
},
|
||||
payload: []byte("hello"),
|
||||
errorString: "script.wasm path must be a string",
|
||||
errorString: "script.wasm path error: not a string",
|
||||
},
|
||||
{
|
||||
name: "non-string function",
|
||||
@@ -121,7 +121,7 @@ func TestBadScriptWASM(t *testing.T) {
|
||||
"function": 12345,
|
||||
},
|
||||
payload: []byte("hello"),
|
||||
errorString: "script.wasm function must be a string",
|
||||
errorString: "script.wasm function error: not a string",
|
||||
},
|
||||
{
|
||||
name: "non-boolean enableWasi",
|
||||
|
||||
@@ -131,7 +131,7 @@ func TestBadStringCreate(t *testing.T) {
|
||||
name: "no template param",
|
||||
payload: "hello",
|
||||
params: map[string]any{},
|
||||
errorString: "string.create requires a template parameter",
|
||||
errorString: "string.create template error: not found",
|
||||
},
|
||||
{
|
||||
name: "non string template",
|
||||
@@ -139,7 +139,7 @@ func TestBadStringCreate(t *testing.T) {
|
||||
params: map[string]any{
|
||||
"template": 1,
|
||||
},
|
||||
errorString: "string.create template must be a string",
|
||||
errorString: "string.create template error: not a string",
|
||||
},
|
||||
{
|
||||
name: "invalid template",
|
||||
|
||||
@@ -126,7 +126,7 @@ func TestBadStringFilter(t *testing.T) {
|
||||
name: "no pattern param",
|
||||
payload: "hello",
|
||||
params: map[string]any{},
|
||||
errorString: "string.filter requires a pattern parameter",
|
||||
errorString: "string.filter pattern error: not found",
|
||||
},
|
||||
{
|
||||
name: "non-string input",
|
||||
@@ -142,7 +142,7 @@ func TestBadStringFilter(t *testing.T) {
|
||||
params: map[string]any{
|
||||
"pattern": 123,
|
||||
},
|
||||
errorString: "string.filter pattern must be a string",
|
||||
errorString: "string.filter pattern error: not a string",
|
||||
},
|
||||
{
|
||||
name: "invalid regex pattern",
|
||||
|
||||
@@ -111,13 +111,13 @@ func TestBadStringSplit(t *testing.T) {
|
||||
name: "missing separator param",
|
||||
payload: "part1,part2,part3",
|
||||
params: map[string]any{},
|
||||
errorString: "string.split requires a separator",
|
||||
errorString: "string.split separator error: not found",
|
||||
},
|
||||
{
|
||||
name: "non-string separator param",
|
||||
payload: "part1,part2,part3",
|
||||
params: map[string]any{"separator": 123},
|
||||
errorString: "string.split separator must be a string",
|
||||
errorString: "string.split separator error: not a string",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ func TestBadTimeSleep(t *testing.T) {
|
||||
name: "no-duration param",
|
||||
payload: "hello",
|
||||
params: map[string]any{},
|
||||
errorString: "time.sleep requires a duration parameter",
|
||||
errorString: "time.sleep duration error: not found",
|
||||
},
|
||||
{
|
||||
name: "non-number duration param",
|
||||
@@ -90,7 +90,7 @@ func TestBadTimeSleep(t *testing.T) {
|
||||
params: map[string]any{
|
||||
"duration": "1000",
|
||||
},
|
||||
errorString: "time.sleep duration must be a number",
|
||||
errorString: "time.sleep duration error: not a number",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -130,25 +130,25 @@ func TestBadUintRandom(t *testing.T) {
|
||||
name: "no min param",
|
||||
payload: "hello",
|
||||
params: map[string]any{"max": 10.0},
|
||||
errorString: "uint.random requires a min parameter",
|
||||
errorString: "uint.random min error: not found",
|
||||
},
|
||||
{
|
||||
name: "no max param",
|
||||
payload: "hello",
|
||||
params: map[string]any{"min": 1.0},
|
||||
errorString: "uint.random requires a max parameter",
|
||||
errorString: "uint.random max error: not found",
|
||||
},
|
||||
{
|
||||
name: "min param not a number",
|
||||
payload: "hello",
|
||||
params: map[string]any{"min": "1", "max": 10.0},
|
||||
errorString: "uint.random min must be a number",
|
||||
errorString: "uint.random min error: not a number",
|
||||
},
|
||||
{
|
||||
name: "max param not a number",
|
||||
payload: "hello",
|
||||
params: map[string]any{"min": 1.0, "max": "10"},
|
||||
errorString: "uint.random max must be a number",
|
||||
errorString: "uint.random max error: not a number",
|
||||
},
|
||||
{
|
||||
name: "max less than min",
|
||||
|
||||
Reference in New Issue
Block a user