add convenience method to pull params from config

This commit is contained in:
Joel Wetzell
2026-03-01 14:57:19 -06:00
parent 183182e6cd
commit c298f63ffc
69 changed files with 591 additions and 1081 deletions

View File

@@ -43,12 +43,12 @@ func TestBadHTTPServer(t *testing.T) {
{
name: "no port param",
params: map[string]any{},
errorString: "http.server requires a port parameter",
errorString: "http.server port error: not found",
},
{
name: "non-numeric port",
params: map[string]any{"port": "3000"},
errorString: "http.server port must be a number",
errorString: "http.server port error: not a number",
},
}

View File

@@ -43,12 +43,12 @@ func TestBadMIDIInput(t *testing.T) {
{
name: "no port param",
params: map[string]any{},
errorString: "midi.input requires a port parameter",
errorString: "midi.input port error: not found",
},
{
name: "non-string port",
params: map[string]any{"port": 123},
errorString: "midi.input port must be a string",
errorString: "midi.input port error: not a string",
},
}

View File

@@ -43,12 +43,12 @@ func TestBadMIDIOutput(t *testing.T) {
{
name: "no port param",
params: map[string]any{},
errorString: "midi.output requires a port parameter",
errorString: "midi.output port error: not found",
},
{
name: "non-string port",
params: map[string]any{"port": 123},
errorString: "midi.output port must be a string",
errorString: "midi.output port error: not a string",
},
}

View File

@@ -48,7 +48,7 @@ func TestBadMQTTClient(t *testing.T) {
"topic": "test/topic",
"clientId": "test",
},
errorString: "mqtt.client requires a broker parameter",
errorString: "mqtt.client broker error: not found",
},
{
name: "non-string broker",
@@ -57,7 +57,7 @@ func TestBadMQTTClient(t *testing.T) {
"topic": "test/topic",
"clientId": "test",
},
errorString: "mqtt.client broker must be a string",
errorString: "mqtt.client broker error: not a string",
},
{
name: "no topic param",
@@ -65,7 +65,7 @@ func TestBadMQTTClient(t *testing.T) {
"broker": "mqtt://localhost:1883",
"clientId": "test",
},
errorString: "mqtt.client requires a topic parameter",
errorString: "mqtt.client topic error: not found",
},
{
name: "non-string topic",
@@ -74,7 +74,7 @@ func TestBadMQTTClient(t *testing.T) {
"topic": 123,
"clientId": "test",
},
errorString: "mqtt.client topic must be a string",
errorString: "mqtt.client topic error: not a string",
},
{
name: "no clientId param",
@@ -82,7 +82,7 @@ func TestBadMQTTClient(t *testing.T) {
"broker": "mqtt://localhost:1883",
"topic": "test/topic",
},
errorString: "mqtt.client requires a clientId parameter",
errorString: "mqtt.client clientId error: not found",
},
{
name: "non-string clientId",
@@ -91,7 +91,7 @@ func TestBadMQTTClient(t *testing.T) {
"topic": "test/topic",
"clientId": 123,
},
errorString: "mqtt.client clientId must be a string",
errorString: "mqtt.client clientId error: not a string",
},
}

View File

@@ -46,7 +46,7 @@ func TestBadNATSClient(t *testing.T) {
params: map[string]any{
"subject": "test/subject",
},
errorString: "nats.client requires a url parameter",
errorString: "nats.client url error: not found",
},
{
name: "non-string url",
@@ -54,14 +54,14 @@ func TestBadNATSClient(t *testing.T) {
"url": 123,
"subject": "test/subject",
},
errorString: "nats.client url must be a string",
errorString: "nats.client url error: not a string",
},
{
name: "no subject param",
params: map[string]any{
"url": "nats://127.0.0.1:4222",
},
errorString: "nats.client requires a subject parameter",
errorString: "nats.client subject error: not found",
},
{
name: "non-string subject",
@@ -69,7 +69,7 @@ func TestBadNATSClient(t *testing.T) {
"url": "nats://127.0.0.1:4222",
"subject": 123,
},
errorString: "nats.client subject must be a string",
errorString: "nats.client subject error: not a string",
},
}

View File

@@ -46,7 +46,7 @@ func TestBadNATSServer(t *testing.T) {
params: map[string]any{
"ip": 123,
},
errorString: "nats.server ip must be a string",
errorString: "nats.server ip error: not a string",
},
}

View File

@@ -47,7 +47,7 @@ func TestBadSerialClient(t *testing.T) {
params: map[string]any{
"framing": "LF",
},
errorString: "serial.client requires a port parameter",
errorString: "serial.client port error: not found",
},
{
name: "non-string port param",
@@ -55,14 +55,14 @@ func TestBadSerialClient(t *testing.T) {
"port": 8000,
"framing": "LF",
},
errorString: "serial.client port must be a string",
errorString: "serial.client port error: not a string",
},
{
name: "no framing param",
params: map[string]any{
"port": "/dev/ttyUSB0",
},
errorString: "serial.client requires a framing parameter",
errorString: "serial.client framing error: not found",
},
{
name: "non-string framing param",
@@ -70,7 +70,7 @@ func TestBadSerialClient(t *testing.T) {
"port": "/dev/ttyUSB0",
"framing": 1,
},
errorString: "serial.client framing method must be a string",
errorString: "serial.client framing error: not a string",
},
{
name: "unkown framing method",

View File

@@ -42,28 +42,28 @@ func TestBadSIPCallServer(t *testing.T) {
params: map[string]any{
"port": "8000",
},
errorString: "sip.call.server port must be a number",
errorString: "sip.call.server port error: not a number",
},
{
name: "non-string ip param",
params: map[string]any{
"ip": 123,
},
errorString: "sip.call.server ip must be a string",
errorString: "sip.call.server ip error: not a string",
},
{
name: "non-string transport param",
params: map[string]any{
"transport": 123,
},
errorString: "sip.call.server transport must be a string",
errorString: "sip.call.server transport error: not a string",
},
{
name: "non-string userAgent param",
params: map[string]any{
"userAgent": 123,
},
errorString: "sip.call.server userAgent must be a string",
errorString: "sip.call.server userAgent error: not a string",
},
}

View File

@@ -43,14 +43,14 @@ func TestBadSIPDTMFServer(t *testing.T) {
{
name: "no separator param",
params: map[string]any{},
errorString: "sip.dtmf.server requires a separator parameter",
errorString: "sip.dtmf.server separator error: not found",
},
{
name: "non-string separator param",
params: map[string]any{
"separator": 123,
},
errorString: "sip.dtmf.server separator must be a string",
errorString: "sip.dtmf.server separator error: not a string",
},
{
name: "non-number port param",
@@ -58,7 +58,7 @@ func TestBadSIPDTMFServer(t *testing.T) {
"separator": "#",
"port": "8000",
},
errorString: "sip.dtmf.server port must be a number",
errorString: "sip.dtmf.server port error: not a number",
},
{
name: "non-string ip param",
@@ -66,7 +66,7 @@ func TestBadSIPDTMFServer(t *testing.T) {
"separator": "#",
"ip": 123,
},
errorString: "sip.dtmf.server ip must be a string",
errorString: "sip.dtmf.server ip error: not a string",
},
{
name: "non-string transport param",
@@ -74,7 +74,7 @@ func TestBadSIPDTMFServer(t *testing.T) {
"separator": "#",
"transport": 123,
},
errorString: "sip.dtmf.server transport must be a string",
errorString: "sip.dtmf.server transport error: not a string",
},
{
name: "non-string userAgent param",
@@ -82,7 +82,7 @@ func TestBadSIPDTMFServer(t *testing.T) {
"separator": "#",
"userAgent": 123,
},
errorString: "sip.dtmf.server userAgent must be a string",
errorString: "sip.dtmf.server userAgent error: not a string",
},
}

View File

@@ -47,7 +47,7 @@ func TestBadTCPClient(t *testing.T) {
params: map[string]any{
"host": "localhost",
},
errorString: "net.tcp.client requires a port parameter",
errorString: "net.tcp.client port error: not found",
},
{
name: "non-number port param",
@@ -55,14 +55,14 @@ func TestBadTCPClient(t *testing.T) {
"host": "localhost",
"port": "8000",
},
errorString: "net.tcp.client port must be a number",
errorString: "net.tcp.client port error: not a number",
},
{
name: "no host param",
params: map[string]any{
"port": 8000.0,
},
errorString: "net.tcp.client requires a host parameter",
errorString: "net.tcp.client host error: not found",
},
{
name: "non-string host param",
@@ -70,7 +70,7 @@ func TestBadTCPClient(t *testing.T) {
"host": 123,
"port": 8000.0,
},
errorString: "net.tcp.client host must be a string",
errorString: "net.tcp.client host error: not a string",
},
}

View File

@@ -46,7 +46,7 @@ func TestBadTCPServer(t *testing.T) {
params: map[string]any{
"framing": "LF",
},
errorString: "net.tcp.server requires a port parameter",
errorString: "net.tcp.server port error: not found",
},
{
name: "non-number port param",
@@ -54,14 +54,14 @@ func TestBadTCPServer(t *testing.T) {
"port": "8000",
"framing": "LF",
},
errorString: "net.tcp.server port must be a number",
errorString: "net.tcp.server port error: not a number",
},
{
name: "no framing param",
params: map[string]any{
"port": 8000.0,
},
errorString: "net.tcp.server requires a framing parameter",
errorString: "net.tcp.server framing error: not found",
},
{
name: "non-string framing param",
@@ -69,7 +69,7 @@ func TestBadTCPServer(t *testing.T) {
"port": 8000.0,
"framing": 1,
},
errorString: "net.tcp.server framing method must be a string",
errorString: "net.tcp.server framing error: not a string",
},
{
name: "unkown framing method",
@@ -86,7 +86,7 @@ func TestBadTCPServer(t *testing.T) {
"framing": "LF",
"ip": 123,
},
errorString: "net.tcp.server ip must be a string",
errorString: "net.tcp.server ip error: not a string",
},
{
name: "invalid addr",

View File

@@ -43,14 +43,14 @@ func TestBadTimeInterval(t *testing.T) {
{
name: "no duration param",
params: map[string]any{},
errorString: "time.interval requires a duration parameter",
errorString: "time.interval duration error: not found",
},
{
name: "non-number duration param",
params: map[string]any{
"duration": "8000",
},
errorString: "time.interval duration must be a number",
errorString: "time.interval duration error: not a number",
},
}

View File

@@ -43,14 +43,14 @@ func TestBadTimeTimer(t *testing.T) {
{
name: "no duration param",
params: map[string]any{},
errorString: "time.timer requires a duration parameter",
errorString: "time.timer duration error: not found",
},
{
name: "non-number duration param",
params: map[string]any{
"duration": "8000",
},
errorString: "time.timer duration must be a number",
errorString: "time.timer duration error: not a number",
},
}

View File

@@ -47,7 +47,7 @@ func TestBadUDPClient(t *testing.T) {
params: map[string]any{
"host": "localhost",
},
errorString: "net.udp.client requires a port parameter",
errorString: "net.udp.client port error: not found",
},
{
name: "non-number port param",
@@ -55,14 +55,14 @@ func TestBadUDPClient(t *testing.T) {
"host": "localhost",
"port": "8000",
},
errorString: "net.udp.client port must be a number",
errorString: "net.udp.client port error: not a number",
},
{
name: "no host param",
params: map[string]any{
"port": 8000.0,
},
errorString: "net.udp.client requires a host parameter",
errorString: "net.udp.client host error: not found",
},
{
name: "non-string host param",
@@ -70,7 +70,7 @@ func TestBadUDPClient(t *testing.T) {
"host": 123,
"port": 8000.0,
},
errorString: "net.udp.client host must be a string",
errorString: "net.udp.client host error: not a string",
},
}

View File

@@ -46,7 +46,7 @@ func TestBadUDPMulticast(t *testing.T) {
params: map[string]any{
"ip": "localhost",
},
errorString: "net.udp.multicast requires a port parameter",
errorString: "net.udp.multicast port error: not found",
},
{
name: "non-number port param",
@@ -54,14 +54,14 @@ func TestBadUDPMulticast(t *testing.T) {
"ip": "localhost",
"port": "8000",
},
errorString: "net.udp.multicast port must be a number",
errorString: "net.udp.multicast port error: not a number",
},
{
name: "no ip param",
params: map[string]any{
"port": 8000.0,
},
errorString: "net.udp.multicast requires an ip parameter",
errorString: "net.udp.multicast ip error: not found",
},
{
name: "non-string ip param",
@@ -69,7 +69,7 @@ func TestBadUDPMulticast(t *testing.T) {
"ip": 123,
"port": 8000.0,
},
errorString: "net.udp.multicast ip must be a string",
errorString: "net.udp.multicast ip error: not a string",
},
{
name: "invalid addr",

View File

@@ -43,14 +43,14 @@ func TestBadUDPServer(t *testing.T) {
{
name: "no port param",
params: map[string]any{},
errorString: "net.udp.server requires a port parameter",
errorString: "net.udp.server port error: not found",
},
{
name: "non-number port param",
params: map[string]any{
"port": "8000",
},
errorString: "net.udp.server port must be a number",
errorString: "net.udp.server port error: not a number",
},
{
name: "non-string ip param",
@@ -58,7 +58,7 @@ func TestBadUDPServer(t *testing.T) {
"port": 8000.0,
"ip": 123,
},
errorString: "net.udp.server ip must be a string",
errorString: "net.udp.server ip error: not a string",
},
{
name: "non-number bufferSize param",
@@ -66,7 +66,7 @@ func TestBadUDPServer(t *testing.T) {
"port": 8000.0,
"bufferSize": "1024",
},
errorString: "net.udp.server bufferSize must be a number",
errorString: "net.udp.server bufferSize error: not a number",
},
{
name: "invalid addr",