mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-09-17 18:52:53 +00:00
rework osc message create syntax
This commit is contained in:
@@ -18,6 +18,7 @@ var (
|
|||||||
ErrParamNotStringSlice = errors.New("not a string slice")
|
ErrParamNotStringSlice = errors.New("not a string slice")
|
||||||
ErrParamNotByteSlice = errors.New("not a byte slice")
|
ErrParamNotByteSlice = errors.New("not a byte slice")
|
||||||
ErrParamNotIntSlice = errors.New("not an int slice")
|
ErrParamNotIntSlice = errors.New("not an int slice")
|
||||||
|
ErrParamNotObjectSlice = errors.New("not an object slice")
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p Params) GetString(key string) (string, error) {
|
func (p Params) GetString(key string) (string, error) {
|
||||||
@@ -143,3 +144,30 @@ func (p Params) GetByteSlice(key string) ([]byte, error) {
|
|||||||
|
|
||||||
return byteSlice, nil
|
return byteSlice, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p Params) GetObjectSlice(key string) ([]map[string]interface{}, error) {
|
||||||
|
value, ok := p[key]
|
||||||
|
if !ok {
|
||||||
|
return nil, ErrParamNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
alreadyObjectSlice, ok := value.([]map[string]interface{})
|
||||||
|
if ok {
|
||||||
|
return alreadyObjectSlice, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
interfaceSlice, ok := value.([]any)
|
||||||
|
if !ok {
|
||||||
|
return nil, ErrParamNotSlice
|
||||||
|
}
|
||||||
|
|
||||||
|
objectSlice := make([]map[string]interface{}, len(interfaceSlice))
|
||||||
|
for i, v := range interfaceSlice {
|
||||||
|
obj, ok := v.(map[string]interface{})
|
||||||
|
if !ok {
|
||||||
|
return nil, ErrParamNotObjectSlice
|
||||||
|
}
|
||||||
|
objectSlice[i] = obj
|
||||||
|
}
|
||||||
|
return objectSlice, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -32,13 +32,22 @@ func init() {
|
|||||||
Description: "arguments for the OSC message",
|
Description: "arguments for the OSC message",
|
||||||
Type: "array",
|
Type: "array",
|
||||||
Items: &jsonschema.Schema{
|
Items: &jsonschema.Schema{
|
||||||
|
Type: "object",
|
||||||
|
Properties: map[string]*jsonschema.Schema{
|
||||||
|
"value": {
|
||||||
|
Title: "Value",
|
||||||
|
Description: "Value of the argument",
|
||||||
|
Type: "string",
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
Title: "Type",
|
||||||
|
Description: "OSC type of the argument",
|
||||||
Type: "string",
|
Type: "string",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"types": {
|
Required: []string{"value", "type"},
|
||||||
Title: "Argument Types",
|
AdditionalProperties: &jsonschema.Schema{Not: &jsonschema.Schema{}},
|
||||||
Description: "string of OSC types corresponding to the arguments in args",
|
},
|
||||||
Type: "string",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Required: []string{"address"},
|
Required: []string{"address"},
|
||||||
@@ -57,7 +66,7 @@ func init() {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
argStrings, err := params.GetStringSlice("args")
|
argObjects, err := params.GetObjectSlice("args")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, config.ErrParamNotFound) {
|
if errors.Is(err, config.ErrParamNotFound) {
|
||||||
return &MessageCreate{config: processorConfig, Address: addressTemplate}, nil
|
return &MessageCreate{config: processorConfig, Address: addressTemplate}, nil
|
||||||
@@ -66,27 +75,39 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typesString, err := params.GetString("types")
|
types := []string{}
|
||||||
if err != nil {
|
for _, argObject := range argObjects {
|
||||||
return nil, fmt.Errorf("osc.message.create types error: %w", err)
|
argType, ok := argObject["type"]
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("osc.message.create arg type error: not found")
|
||||||
}
|
}
|
||||||
|
argTypeStr, ok := argType.(string)
|
||||||
if len(argStrings) != len(typesString) {
|
if !ok {
|
||||||
return nil, errors.New("osc.message.create args and types must be the same length")
|
return nil, errors.New("osc.message.create arg type error: not a string")
|
||||||
|
}
|
||||||
|
types = append(types, argTypeStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
argTemplates := []*template.Template{}
|
argTemplates := []*template.Template{}
|
||||||
|
|
||||||
for _, argString := range argStrings {
|
for _, argObject := range argObjects {
|
||||||
|
argValue, ok := argObject["value"]
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("osc.message.create arg value error: not found")
|
||||||
|
}
|
||||||
|
argValueStr, ok := argValue.(string)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("osc.message.create arg value error: not a string")
|
||||||
|
}
|
||||||
|
|
||||||
argTemplate, err := template.New("arg").Parse(argString)
|
argTemplate, err := template.New("arg").Parse(argValueStr)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
argTemplates = append(argTemplates, argTemplate)
|
argTemplates = append(argTemplates, argTemplate)
|
||||||
}
|
}
|
||||||
return &MessageCreate{config: processorConfig, Address: addressTemplate, Args: argTemplates, Types: typesString}, nil
|
return &MessageCreate{config: processorConfig, Address: addressTemplate, Args: argTemplates, Types: types}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -95,7 +116,7 @@ type MessageCreate struct {
|
|||||||
config config.ProcessorConfig
|
config config.ProcessorConfig
|
||||||
Address *template.Template
|
Address *template.Template
|
||||||
Args []*template.Template
|
Args []*template.Template
|
||||||
Types string
|
Types []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (omc *MessageCreate) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
|
func (omc *MessageCreate) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
|
||||||
@@ -165,15 +186,15 @@ func (omc *MessageCreate) Type() string {
|
|||||||
return omc.config.Type
|
return omc.config.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
func argToTypedArg(rawArg string, oscType byte) (osc.Arg, error) {
|
func argToTypedArg(rawArg string, oscType string) (osc.Arg, error) {
|
||||||
|
|
||||||
switch oscType {
|
switch oscType {
|
||||||
case 's':
|
case "s":
|
||||||
return osc.Arg{
|
return osc.Arg{
|
||||||
Value: rawArg,
|
Value: rawArg,
|
||||||
Type: "s",
|
Type: "s",
|
||||||
}, nil
|
}, nil
|
||||||
case 'i':
|
case "i":
|
||||||
number, err := strconv.ParseInt(rawArg, 10, 32)
|
number, err := strconv.ParseInt(rawArg, 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return osc.Arg{}, err
|
return osc.Arg{}, err
|
||||||
@@ -182,7 +203,7 @@ func argToTypedArg(rawArg string, oscType byte) (osc.Arg, error) {
|
|||||||
Value: int32(number),
|
Value: int32(number),
|
||||||
Type: "i",
|
Type: "i",
|
||||||
}, nil
|
}, nil
|
||||||
case 'f':
|
case "f":
|
||||||
number, err := strconv.ParseFloat(rawArg, 32)
|
number, err := strconv.ParseFloat(rawArg, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return osc.Arg{}, err
|
return osc.Arg{}, err
|
||||||
@@ -191,7 +212,7 @@ func argToTypedArg(rawArg string, oscType byte) (osc.Arg, error) {
|
|||||||
Value: float32(number),
|
Value: float32(number),
|
||||||
Type: "f",
|
Type: "f",
|
||||||
}, nil
|
}, nil
|
||||||
case 'b':
|
case "b":
|
||||||
data, err := hex.DecodeString(rawArg)
|
data, err := hex.DecodeString(rawArg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return osc.Arg{}, err
|
return osc.Arg{}, err
|
||||||
@@ -200,7 +221,7 @@ func argToTypedArg(rawArg string, oscType byte) (osc.Arg, error) {
|
|||||||
Value: data,
|
Value: data,
|
||||||
Type: "b",
|
Type: "b",
|
||||||
}, nil
|
}, nil
|
||||||
case 'h':
|
case "h":
|
||||||
number, err := strconv.ParseInt(rawArg, 10, 64)
|
number, err := strconv.ParseInt(rawArg, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return osc.Arg{}, err
|
return osc.Arg{}, err
|
||||||
@@ -209,7 +230,7 @@ func argToTypedArg(rawArg string, oscType byte) (osc.Arg, error) {
|
|||||||
Value: int64(number),
|
Value: int64(number),
|
||||||
Type: "h",
|
Type: "h",
|
||||||
}, nil
|
}, nil
|
||||||
case 'd':
|
case "d":
|
||||||
number, err := strconv.ParseFloat(rawArg, 64)
|
number, err := strconv.ParseFloat(rawArg, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return osc.Arg{}, err
|
return osc.Arg{}, err
|
||||||
@@ -218,22 +239,22 @@ func argToTypedArg(rawArg string, oscType byte) (osc.Arg, error) {
|
|||||||
Value: float64(number),
|
Value: float64(number),
|
||||||
Type: "d",
|
Type: "d",
|
||||||
}, nil
|
}, nil
|
||||||
case 'T':
|
case "T":
|
||||||
return osc.Arg{
|
return osc.Arg{
|
||||||
Value: true,
|
Value: true,
|
||||||
Type: "T",
|
Type: "T",
|
||||||
}, nil
|
}, nil
|
||||||
case 'F':
|
case "F":
|
||||||
return osc.Arg{
|
return osc.Arg{
|
||||||
Value: false,
|
Value: false,
|
||||||
Type: "F",
|
Type: "F",
|
||||||
}, nil
|
}, nil
|
||||||
case 'N':
|
case "N":
|
||||||
return osc.Arg{
|
return osc.Arg{
|
||||||
Value: nil,
|
Value: nil,
|
||||||
Type: "N",
|
Type: "N",
|
||||||
}, nil
|
}, nil
|
||||||
default:
|
default:
|
||||||
return osc.Arg{}, fmt.Errorf("osc.message.create unhandled osc type: %c", oscType)
|
return osc.Arg{}, fmt.Errorf("osc.message.create unhandled osc type: %s", oscType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,8 +64,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
|||||||
name: "address with template and string arg",
|
name: "address with template and string arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test/{{.Payload.Value}}",
|
"address": "/test/{{.Payload.Value}}",
|
||||||
"args": []any{"arg1"},
|
"args": []map[string]any{{"value": "arg1", "type": "s"}},
|
||||||
"types": "s",
|
|
||||||
},
|
},
|
||||||
payload: map[string]any{"Value": "value"},
|
payload: map[string]any{"Value": "value"},
|
||||||
expected: &osc.Message{Address: "/test/value", Args: []osc.Arg{{Value: "arg1", Type: "s"}}},
|
expected: &osc.Message{Address: "/test/value", Args: []osc.Arg{{Value: "arg1", Type: "s"}}},
|
||||||
@@ -74,8 +73,11 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
|||||||
name: "address with template and mixed args",
|
name: "address with template and mixed args",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test/{{.Payload.Value}}",
|
"address": "/test/{{.Payload.Value}}",
|
||||||
"args": []any{"arg1", "42", "3.14"},
|
"args": []map[string]any{
|
||||||
"types": "sif",
|
{"value": "arg1", "type": "s"},
|
||||||
|
{"value": "42", "type": "i"},
|
||||||
|
{"value": "3.14", "type": "f"},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
payload: map[string]any{"Value": "value"},
|
payload: map[string]any{"Value": "value"},
|
||||||
expected: &osc.Message{
|
expected: &osc.Message{
|
||||||
@@ -91,8 +93,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
|||||||
name: "address with template and int64 arg",
|
name: "address with template and int64 arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test/{{.Payload.Value}}",
|
"address": "/test/{{.Payload.Value}}",
|
||||||
"args": []any{"42"},
|
"args": []map[string]any{{"value": "42", "type": "h"}},
|
||||||
"types": "h",
|
|
||||||
},
|
},
|
||||||
payload: map[string]any{"Value": "value"},
|
payload: map[string]any{"Value": "value"},
|
||||||
expected: &osc.Message{Address: "/test/value", Args: []osc.Arg{{Value: int64(42), Type: "h"}}},
|
expected: &osc.Message{Address: "/test/value", Args: []osc.Arg{{Value: int64(42), Type: "h"}}},
|
||||||
@@ -101,8 +102,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
|||||||
name: "address with template and double arg",
|
name: "address with template and double arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test/{{.Payload.Value}}",
|
"address": "/test/{{.Payload.Value}}",
|
||||||
"args": []any{"42"},
|
"args": []map[string]any{{"value": "42", "type": "d"}},
|
||||||
"types": "d",
|
|
||||||
},
|
},
|
||||||
payload: map[string]any{"Value": "value"},
|
payload: map[string]any{"Value": "value"},
|
||||||
expected: &osc.Message{Address: "/test/value", Args: []osc.Arg{{Value: float64(42), Type: "d"}}},
|
expected: &osc.Message{Address: "/test/value", Args: []osc.Arg{{Value: float64(42), Type: "d"}}},
|
||||||
@@ -111,8 +111,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
|||||||
name: "address with template and true arg",
|
name: "address with template and true arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test/{{.Payload.Value}}",
|
"address": "/test/{{.Payload.Value}}",
|
||||||
"args": []any{""},
|
"args": []map[string]any{{"value": "", "type": "T"}},
|
||||||
"types": "T",
|
|
||||||
},
|
},
|
||||||
payload: map[string]any{"Value": "value"},
|
payload: map[string]any{"Value": "value"},
|
||||||
expected: &osc.Message{Address: "/test/value", Args: []osc.Arg{{Value: true, Type: "T"}}},
|
expected: &osc.Message{Address: "/test/value", Args: []osc.Arg{{Value: true, Type: "T"}}},
|
||||||
@@ -121,8 +120,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
|||||||
name: "address with template and false arg",
|
name: "address with template and false arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test/{{.Payload.Value}}",
|
"address": "/test/{{.Payload.Value}}",
|
||||||
"args": []any{""},
|
"args": []map[string]any{{"value": "", "type": "F"}},
|
||||||
"types": "F",
|
|
||||||
},
|
},
|
||||||
payload: map[string]any{"Value": "value"},
|
payload: map[string]any{"Value": "value"},
|
||||||
expected: &osc.Message{Address: "/test/value", Args: []osc.Arg{{Value: false, Type: "F"}}},
|
expected: &osc.Message{Address: "/test/value", Args: []osc.Arg{{Value: false, Type: "F"}}},
|
||||||
@@ -131,8 +129,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
|||||||
name: "address with template and nil arg",
|
name: "address with template and nil arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test/{{.Payload.Value}}",
|
"address": "/test/{{.Payload.Value}}",
|
||||||
"args": []any{""},
|
"args": []map[string]any{{"value": "", "type": "N"}},
|
||||||
"types": "N",
|
|
||||||
},
|
},
|
||||||
payload: map[string]any{"Value": "value"},
|
payload: map[string]any{"Value": "value"},
|
||||||
expected: &osc.Message{Address: "/test/value", Args: []osc.Arg{{Value: nil, Type: "N"}}},
|
expected: &osc.Message{Address: "/test/value", Args: []osc.Arg{{Value: nil, Type: "N"}}},
|
||||||
@@ -141,8 +138,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
|||||||
name: "blob arg",
|
name: "blob arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []any{"deadbeef"},
|
"args": []map[string]any{{"value": "deadbeef", "type": "b"}},
|
||||||
"types": "b",
|
|
||||||
},
|
},
|
||||||
payload: "",
|
payload: "",
|
||||||
expected: &osc.Message{Address: "/test", Args: []osc.Arg{{Value: []byte{0xde, 0xad, 0xbe, 0xef}, Type: "b"}}},
|
expected: &osc.Message{Address: "/test", Args: []osc.Arg{{Value: []byte{0xde, 0xad, 0xbe, 0xef}, Type: "b"}}},
|
||||||
@@ -224,66 +220,51 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
|||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": "not an array",
|
"args": "not an array",
|
||||||
"types": "s",
|
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
errorString: "osc.message.create args error: not a slice",
|
errorString: "osc.message.create args error: not a slice",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "args without types parameter",
|
name: "args not an object array",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []any{"arg1"},
|
"args": []any{"arg1"},
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
errorString: "osc.message.create types error: not found",
|
errorString: "osc.message.create args error: not an object slice",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "args and types length mismatch",
|
name: "arg value not a string",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []any{"arg1", "arg2"},
|
"args": []map[string]any{{"value": 123, "type": "s"}},
|
||||||
"types": "s",
|
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
errorString: "osc.message.create args and types must be the same length",
|
errorString: "osc.message.create arg value error: not a string",
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "non-string arg",
|
|
||||||
params: map[string]any{
|
|
||||||
"address": "/test",
|
|
||||||
"args": []any{"arg1", 123},
|
|
||||||
"types": "ss",
|
|
||||||
},
|
|
||||||
payload: "test",
|
|
||||||
errorString: "osc.message.create args error: not a string slice",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "bad arg template",
|
name: "bad arg template",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []any{"{{"},
|
"args": []map[string]any{{"value": "{{", "type": "s"}},
|
||||||
"types": "s",
|
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
errorString: "template: arg:1: unclosed action",
|
errorString: "template: arg:1: unclosed action",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "non-string types parameter",
|
name: "non-string type parameter",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []any{"arg1"},
|
"args": []map[string]any{{"value": "arg1", "type": 123}},
|
||||||
"types": 123,
|
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
errorString: "osc.message.create types error: not a string",
|
errorString: "osc.message.create arg type error: not a string",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "invalid type in types parameter",
|
name: "invalid type in types parameter",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []any{"arg1"},
|
"args": []map[string]any{{"value": "arg1", "type": "x"}},
|
||||||
"types": "x",
|
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
errorString: "osc.message.create unhandled osc type: x",
|
errorString: "osc.message.create unhandled osc type: x",
|
||||||
@@ -313,11 +294,10 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
|||||||
errorString: "osc.message.create address must start with '/'",
|
errorString: "osc.message.create address must start with '/'",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "address template with missing field",
|
name: "arg template with missing field",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []any{"{{.missing}}"},
|
"args": []map[string]any{{"value": "{{.missing}}", "type": "s"}},
|
||||||
"types": "s",
|
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
errorString: "template: arg:1:2: executing \"arg\" at <.missing>: can't evaluate field missing in type common.WrappedPayload",
|
errorString: "template: arg:1:2: executing \"arg\" at <.missing>: can't evaluate field missing in type common.WrappedPayload",
|
||||||
@@ -326,8 +306,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
|||||||
name: "wrong arg type for int arg",
|
name: "wrong arg type for int arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []any{"{{.Payload}}"},
|
"args": []map[string]any{{"value": "{{.Payload}}", "type": "i"}},
|
||||||
"types": "i",
|
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
errorString: "strconv.ParseInt: parsing \"test\": invalid syntax",
|
errorString: "strconv.ParseInt: parsing \"test\": invalid syntax",
|
||||||
@@ -336,8 +315,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
|||||||
name: "wrong arg type for float arg",
|
name: "wrong arg type for float arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []any{"{{.Payload}}"},
|
"args": []map[string]any{{"value": "{{.Payload}}", "type": "f"}},
|
||||||
"types": "f",
|
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
errorString: "strconv.ParseFloat: parsing \"test\": invalid syntax",
|
errorString: "strconv.ParseFloat: parsing \"test\": invalid syntax",
|
||||||
@@ -346,8 +324,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
|||||||
name: "wrong arg type for blob arg",
|
name: "wrong arg type for blob arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []any{"{{.Payload}}"},
|
"args": []map[string]any{{"value": "{{.Payload}}", "type": "b"}},
|
||||||
"types": "b",
|
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
errorString: "encoding/hex: invalid byte: U+0074 't'",
|
errorString: "encoding/hex: invalid byte: U+0074 't'",
|
||||||
@@ -356,8 +333,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
|||||||
name: "wrong arg type for int64 arg",
|
name: "wrong arg type for int64 arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []any{"{{.Payload}}"},
|
"args": []map[string]any{{"value": "{{.Payload}}", "type": "h"}},
|
||||||
"types": "h",
|
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
errorString: "strconv.ParseInt: parsing \"test\": invalid syntax",
|
errorString: "strconv.ParseInt: parsing \"test\": invalid syntax",
|
||||||
@@ -366,8 +342,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
|||||||
name: "wrong arg type for double arg",
|
name: "wrong arg type for double arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []any{"{{.Payload}}"},
|
"args": []map[string]any{{"value": "{{.Payload}}", "type": "d"}},
|
||||||
"types": "d",
|
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
errorString: "strconv.ParseFloat: parsing \"test\": invalid syntax",
|
errorString: "strconv.ParseFloat: parsing \"test\": invalid syntax",
|
||||||
@@ -416,8 +391,7 @@ func BenchmarkOSCMessageCreate(b *testing.B) {
|
|||||||
Type: "osc.message.create",
|
Type: "osc.message.create",
|
||||||
Params: map[string]any{
|
Params: map[string]any{
|
||||||
"address": "/hello",
|
"address": "/hello",
|
||||||
"args": []any{"{{.Payload}}"},
|
"args": []map[string]any{{"value": "{{.Payload}}", "type": "i"}},
|
||||||
"types": "i",
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user