From 8cb2a0e9f0893bb12f902fb692177491affe002b Mon Sep 17 00:00:00 2001 From: Joel Wetzell Date: Tue, 10 Feb 2026 21:23:11 -0600 Subject: [PATCH] add more tests for osc.message.create --- .../processor/test/osc-message-create_test.go | 88 ++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/internal/processor/test/osc-message-create_test.go b/internal/processor/test/osc-message-create_test.go index 5abbcaf..ac62c3c 100644 --- a/internal/processor/test/osc-message-create_test.go +++ b/internal/processor/test/osc-message-create_test.go @@ -64,6 +64,73 @@ func TestGoodOSCMessageCreate(t *testing.T) { payload: map[string]any{"Value": "value"}, expected: osc.OSCMessage{Address: "/test/value", Args: []osc.OSCArg{{Value: "arg1", Type: "s"}}}, }, + { + name: "address with template and mixed args", + params: map[string]any{ + "address": "/test/{{.Value}}", + "args": []interface{}{"arg1", "42", "3.14"}, + "types": "sif", + }, + payload: map[string]any{"Value": "value"}, + expected: osc.OSCMessage{ + Address: "/test/value", + Args: []osc.OSCArg{ + {Value: "arg1", Type: "s"}, + {Value: int32(42), Type: "i"}, + {Value: float32(3.14), Type: "f"}, + }, + }, + }, + { + name: "address with template and int64 arg", + params: map[string]any{ + "address": "/test/{{.Value}}", + "args": []interface{}{"42"}, + "types": "h", + }, + payload: map[string]any{"Value": "value"}, + expected: osc.OSCMessage{Address: "/test/value", Args: []osc.OSCArg{{Value: int64(42), Type: "h"}}}, + }, + { + name: "address with template and double arg", + params: map[string]any{ + "address": "/test/{{.Value}}", + "args": []interface{}{"42"}, + "types": "d", + }, + payload: map[string]any{"Value": "value"}, + expected: osc.OSCMessage{Address: "/test/value", Args: []osc.OSCArg{{Value: float64(42), Type: "d"}}}, + }, + { + name: "address with template and true arg", + params: map[string]any{ + "address": "/test/{{.Value}}", + "args": []interface{}{""}, + "types": "T", + }, + payload: map[string]any{"Value": "value"}, + expected: osc.OSCMessage{Address: "/test/value", Args: []osc.OSCArg{{Value: true, Type: "T"}}}, + }, + { + name: "address with template and false arg", + params: map[string]any{ + "address": "/test/{{.Value}}", + "args": []interface{}{""}, + "types": "F", + }, + payload: map[string]any{"Value": "value"}, + expected: osc.OSCMessage{Address: "/test/value", Args: []osc.OSCArg{{Value: false, Type: "F"}}}, + }, + { + name: "address with template and nil arg", + params: map[string]any{ + "address": "/test/{{.Value}}", + "args": []interface{}{""}, + "types": "N", + }, + payload: map[string]any{"Value": "value"}, + expected: osc.OSCMessage{Address: "/test/value", Args: []osc.OSCArg{{Value: nil, Type: "N"}}}, + }, } for _, test := range tests { @@ -146,6 +213,15 @@ func TestBadOSCMessageCreate(t *testing.T) { payload: "test", errorString: "osc.message.create address must be an array found string", }, + { + name: "args without types parameter", + params: map[string]any{ + "address": "/test", + "args": []interface{}{"arg1"}, + }, + payload: "test", + errorString: "osc.message.create requires a types parameter with args", + }, { name: "args and types length mismatch", params: map[string]any{ @@ -205,7 +281,7 @@ func TestBadOSCMessageCreate(t *testing.T) { errorString: "osc.message.create address must not be empty", }, { - name: "template with missing value", + name: "address template with missing value", params: map[string]any{ "address": "/test/{{.missing}}", }, @@ -220,6 +296,16 @@ func TestBadOSCMessageCreate(t *testing.T) { payload: "test", errorString: "osc.message.create address must start with '/'", }, + { + name: "address template with missing field", + params: map[string]any{ + "address": "/test", + "args": []interface{}{"{{.missing}}"}, + "types": "s", + }, + payload: "test", + errorString: "template: arg:1:2: executing \"arg\" at <.missing>: can't evaluate field missing in type string", + }, } for _, test := range tests {