mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-05-07 10:05:54 +00:00
pull all non-request scoped values out of context
This commit is contained in:
@@ -20,14 +20,12 @@ type RouterInput struct {
|
||||
func (ro *RouterInput) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
|
||||
|
||||
payload := wrappedPayload.Payload
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
if !ok {
|
||||
|
||||
if wrappedPayload.Router == nil {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, errors.New("router.input no router found")
|
||||
}
|
||||
|
||||
_, err := router.HandleInput(ctx, ro.SourceId, payload)
|
||||
_, err := wrappedPayload.Router.HandleInput(ctx, ro.SourceId, payload)
|
||||
|
||||
if err != nil {
|
||||
wrappedPayload.End = true
|
||||
|
||||
@@ -19,13 +19,12 @@ type RouterOutput struct {
|
||||
|
||||
func (ro *RouterOutput) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
|
||||
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
if !ok {
|
||||
if wrappedPayload.Router == nil {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, errors.New("router.output no router found")
|
||||
}
|
||||
|
||||
err := router.HandleOutput(ctx, ro.ModuleId, wrappedPayload.Payload)
|
||||
err := wrappedPayload.Router.HandleOutput(ctx, ro.ModuleId, wrappedPayload.Payload)
|
||||
|
||||
if err != nil {
|
||||
wrappedPayload.End = true
|
||||
|
||||
@@ -34,8 +34,6 @@ func (sj *ScriptJS) Process(ctx context.Context, wrappedPayload common.WrappedPa
|
||||
|
||||
sj.vm.SetProperty(sj.vm.GlobalObject(), sj.payloadAtom, wrappedPayload.Payload)
|
||||
|
||||
sj.vm.SetProperty(sj.vm.GlobalObject(), sj.senderAtom, wrappedPayload.Sender)
|
||||
|
||||
_, err := sj.vm.Eval(sj.Program, quickjs.EvalGlobal)
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -58,7 +58,7 @@ func TestGoodArtnetPacketDecode(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
got, err := packetDecoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := packetDecoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("artnet.packet.decode processing failed: %s", err)
|
||||
@@ -94,7 +94,7 @@ func TestBadArtnetPacketDecode(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
got, err := packetDecoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := packetDecoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("artnet.packet.decode expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -58,7 +58,7 @@ func TestGoodArtnetPacketEncode(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
got, err := packetEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := packetEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("artnet.packet.encode processing failed: %s", err)
|
||||
@@ -89,7 +89,7 @@ func TestBadArtnetPacketEncode(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
got, err := packetEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := packetEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("artnet.packet.encode expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package processor_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@@ -36,12 +35,12 @@ func TestDbQueryFromRegistry(t *testing.T) {
|
||||
payload := "hello"
|
||||
expected := map[string]any{"sqlite_version()": "3.53.0"}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(test.GetContextWithModules(
|
||||
t.Context(),
|
||||
map[string]common.Module{
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
|
||||
Payload: payload,
|
||||
Modules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
},
|
||||
), payload))
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("db.query processing failed: %s", err)
|
||||
}
|
||||
@@ -115,12 +114,12 @@ func TestGoodDbQuery(t *testing.T) {
|
||||
t.Fatalf("db.query failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(test.GetContextWithModules(
|
||||
t.Context(),
|
||||
map[string]common.Module{
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
|
||||
Modules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
},
|
||||
), testCase.payload))
|
||||
Payload: testCase.payload,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("db.query processing failed: %s", err)
|
||||
@@ -135,11 +134,11 @@ func TestGoodDbQuery(t *testing.T) {
|
||||
|
||||
func TestBadDbQuery(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
wrappedPayloadCtx context.Context
|
||||
errorString string
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
wrappedPayloadModules map[string]common.Module
|
||||
errorString string
|
||||
}{
|
||||
{
|
||||
name: "no module param",
|
||||
@@ -147,9 +146,9 @@ func TestBadDbQuery(t *testing.T) {
|
||||
params: map[string]any{
|
||||
"query": "SELECT sqlite_version();",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "db.query module error: not found",
|
||||
},
|
||||
{
|
||||
@@ -159,9 +158,9 @@ func TestBadDbQuery(t *testing.T) {
|
||||
"module": 1,
|
||||
"query": "SELECT sqlite_version();",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "db.query module error: not a string",
|
||||
},
|
||||
{
|
||||
@@ -170,9 +169,9 @@ func TestBadDbQuery(t *testing.T) {
|
||||
params: map[string]any{
|
||||
"module": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "db.query query error: not found",
|
||||
},
|
||||
{
|
||||
@@ -182,9 +181,9 @@ func TestBadDbQuery(t *testing.T) {
|
||||
"module": "test",
|
||||
"query": 1,
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "db.query query error: not a string",
|
||||
},
|
||||
{
|
||||
@@ -194,9 +193,9 @@ func TestBadDbQuery(t *testing.T) {
|
||||
"module": "test",
|
||||
"query": "select * from {{",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "template: query:1: unclosed action",
|
||||
},
|
||||
{
|
||||
@@ -206,9 +205,9 @@ func TestBadDbQuery(t *testing.T) {
|
||||
"module": "test",
|
||||
"query": "select * from {{.Data}}",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "template: query:1:16: executing \"query\" at <.Data>: can't evaluate field Data in type common.WrappedPayload",
|
||||
},
|
||||
{
|
||||
@@ -218,9 +217,9 @@ func TestBadDbQuery(t *testing.T) {
|
||||
"module": "test",
|
||||
"query": "select * from asdf;",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "db.query error executing query: SQL logic error: no such table: asdf (1)",
|
||||
},
|
||||
{
|
||||
@@ -230,8 +229,8 @@ func TestBadDbQuery(t *testing.T) {
|
||||
"module": "test",
|
||||
"query": "select * from test;",
|
||||
},
|
||||
wrappedPayloadCtx: t.Context(),
|
||||
errorString: "db.query wrapped payload has no modules",
|
||||
wrappedPayloadModules: nil,
|
||||
errorString: "db.query wrapped payload has no modules",
|
||||
},
|
||||
{
|
||||
name: "module not found in context",
|
||||
@@ -240,8 +239,8 @@ func TestBadDbQuery(t *testing.T) {
|
||||
"module": "test",
|
||||
"query": "select * from test;",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{}),
|
||||
errorString: "db.query unable to find module with id: test",
|
||||
wrappedPayloadModules: map[string]common.Module{},
|
||||
errorString: "db.query unable to find module with id: test",
|
||||
},
|
||||
{
|
||||
name: "module not found in context",
|
||||
@@ -250,8 +249,8 @@ func TestBadDbQuery(t *testing.T) {
|
||||
"module": "test",
|
||||
"query": "select * from test;",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{}),
|
||||
errorString: "db.query unable to find module with id: test",
|
||||
wrappedPayloadModules: map[string]common.Module{},
|
||||
errorString: "db.query unable to find module with id: test",
|
||||
},
|
||||
{
|
||||
name: "module not a DatabseModule",
|
||||
@@ -260,9 +259,9 @@ func TestBadDbQuery(t *testing.T) {
|
||||
"module": "test",
|
||||
"query": "select * from test;",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestKVModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "db.query module with id test is not a DatabaseModule",
|
||||
},
|
||||
}
|
||||
@@ -287,7 +286,10 @@ func TestBadDbQuery(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(test.wrappedPayloadCtx, test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
|
||||
Payload: test.payload,
|
||||
Modules: test.wrappedPayloadModules,
|
||||
})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("db.query expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -30,7 +30,7 @@ func TestDebugLogFromRegistry(t *testing.T) {
|
||||
payload := "test"
|
||||
expected := "test"
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("debug.log processing failed: %s", err)
|
||||
}
|
||||
@@ -66,7 +66,7 @@ func TestGoodDebugLog(t *testing.T) {
|
||||
t.Fatalf("debug.log failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("debug.log processing failed: %s", err)
|
||||
}
|
||||
@@ -106,7 +106,7 @@ func TestBadDebugLog(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("debug.log expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -29,7 +29,9 @@ func TestFilterChangeFromRegistry(t *testing.T) {
|
||||
payload := "hello"
|
||||
expected := "hello"
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
|
||||
Payload: payload,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("filter.change processing failed: %s", err)
|
||||
}
|
||||
@@ -70,7 +72,7 @@ func TestGoodFilterChange(t *testing.T) {
|
||||
t.Fatalf("filter.change failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("filter.change processing failed: %s", err)
|
||||
@@ -110,7 +112,7 @@ func TestBadFilterChange(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("filter.change expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -85,7 +85,7 @@ func TestGoodFilterExpr(t *testing.T) {
|
||||
t.Fatalf("filter.expr failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), testCase.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: testCase.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("filter.expr processing failed: %s", err)
|
||||
@@ -159,7 +159,7 @@ func TestBadFilterExpr(t *testing.T) {
|
||||
}
|
||||
return
|
||||
}
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("filter.expr expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestFilterRegexFromRegistry(t *testing.T) {
|
||||
payload := "hello"
|
||||
expected := "hello"
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("filter.regex processing failed: %s", err)
|
||||
}
|
||||
@@ -90,7 +90,7 @@ func TestGoodFilterRegex(t *testing.T) {
|
||||
t.Fatalf("filter.regex failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("filter.regex processing failed: %s", err)
|
||||
@@ -161,7 +161,7 @@ func TestBadFilterRegex(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("filter.regex expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -76,7 +76,7 @@ func TestGoodFloatParse(t *testing.T) {
|
||||
t.Fatalf("float.parse failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("float.parse processing failed: %s", err)
|
||||
}
|
||||
@@ -152,7 +152,7 @@ func TestBadFloatParse(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("float.parse expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -71,7 +71,7 @@ func TestGoodFloatRandom(t *testing.T) {
|
||||
t.Fatalf("float.random failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("float.random processing failed: %s", err)
|
||||
}
|
||||
@@ -172,7 +172,7 @@ func TestBadFloatRandom(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("float.random expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -103,7 +103,7 @@ func TestGoodFreeDCreate(t *testing.T) {
|
||||
t.Fatalf("freed.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("freed.create processing failed: %s", err)
|
||||
}
|
||||
@@ -865,7 +865,7 @@ func TestBadFreeDCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("freed.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestGoodFreeDDecode(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
got, err := packetEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := packetEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("freed.decode processing failed: %s", err)
|
||||
@@ -90,7 +90,7 @@ func TestBadFreeDDecode(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
got, err := packetEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := packetEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("freed.decode expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestGoodFreeDEncode(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
got, err := packetEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := packetEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("freed.encode processing failed: %s", err)
|
||||
@@ -90,7 +90,7 @@ func TestBadFreeDEncode(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
got, err := packetEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := packetEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("freed.encode expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -58,7 +58,7 @@ func TestGoodHTTPRequestDo(t *testing.T) {
|
||||
t.Fatalf("http.request.do failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("http.request.do processing failed: %s", err)
|
||||
}
|
||||
@@ -149,7 +149,7 @@ func TestBadHTTPRequestDo(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("http.request.do expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -68,7 +68,7 @@ func TestGoodHTTPResponseCreate(t *testing.T) {
|
||||
t.Fatalf("http.response.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("http.response.create processing failed: %s", err)
|
||||
}
|
||||
@@ -145,7 +145,7 @@ func TestBadHTTPResponseCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("http.response.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -97,7 +97,7 @@ func TestGoodIntParse(t *testing.T) {
|
||||
t.Fatalf("int.parse failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("int.parse processing failed: %s", err)
|
||||
}
|
||||
@@ -186,7 +186,7 @@ func TestBadIntParse(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("int.parse expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -51,7 +51,7 @@ func TestIntRandomGoodConfig(t *testing.T) {
|
||||
|
||||
payload := "12345"
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("int.random processing failed: %s", err)
|
||||
}
|
||||
@@ -98,7 +98,7 @@ func TestGoodIntRandom(t *testing.T) {
|
||||
t.Fatalf("int.random failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("int.random processing failed: %s", err)
|
||||
}
|
||||
@@ -183,7 +183,7 @@ func TestBadIntRandom(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("int.random expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -69,7 +69,7 @@ func TestGoodIntScale(t *testing.T) {
|
||||
t.Fatalf("int.scale failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("int.scale processing failed: %s", err)
|
||||
}
|
||||
@@ -157,7 +157,7 @@ func TestBadIntScale(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("int.scale expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestJsonDecodeFromRegistry(t *testing.T) {
|
||||
"property": "hello",
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("json.decode processing failed: %s", err)
|
||||
}
|
||||
@@ -75,7 +75,7 @@ func TestGoodJsonDecode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := jsonDecoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := jsonDecoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("json.decode processing failed: %s", err)
|
||||
}
|
||||
@@ -113,7 +113,7 @@ func TestBadJsonDecode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := stringEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := stringEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("json.decode expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -35,7 +35,7 @@ func TestJsonEncodeFromRegistry(t *testing.T) {
|
||||
|
||||
expected := []byte("{\"property\":\"hello\"}")
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("json.encode processing failed: %s", err)
|
||||
}
|
||||
@@ -69,7 +69,7 @@ func TestGoodJsonEncode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := jsonEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := jsonEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("json.encode processing failed: %s", err)
|
||||
}
|
||||
@@ -102,7 +102,7 @@ func TestBadJsonEncode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := stringEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := stringEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("json.encode expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package processor_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@@ -35,12 +34,12 @@ func TestKvGetFromRegistry(t *testing.T) {
|
||||
payload := "hello"
|
||||
expected := "test"
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(test.GetContextWithModules(
|
||||
t.Context(),
|
||||
map[string]common.Module{
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
|
||||
Modules: map[string]common.Module{
|
||||
"test": test.NewTestKVModule("test"),
|
||||
},
|
||||
), payload))
|
||||
Payload: payload,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("kv.get processing failed: %s", err)
|
||||
}
|
||||
@@ -95,12 +94,12 @@ func TestGoodKvGet(t *testing.T) {
|
||||
t.Fatalf("kv.get failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(test.GetContextWithModules(
|
||||
t.Context(),
|
||||
map[string]common.Module{
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
|
||||
Modules: map[string]common.Module{
|
||||
"test": test.NewTestKVModule("test"),
|
||||
},
|
||||
), testCase.payload))
|
||||
Payload: testCase.payload,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("kv.get processing failed: %s", err)
|
||||
@@ -115,11 +114,11 @@ func TestGoodKvGet(t *testing.T) {
|
||||
|
||||
func TestBadKvGet(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
wrappedPayloadCtx context.Context
|
||||
errorString string
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
wrappedPayloadModules map[string]common.Module
|
||||
errorString string
|
||||
}{
|
||||
{
|
||||
name: "no module param",
|
||||
@@ -127,9 +126,9 @@ func TestBadKvGet(t *testing.T) {
|
||||
params: map[string]any{
|
||||
"key": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestKVModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "kv.get module error: not found",
|
||||
},
|
||||
{
|
||||
@@ -139,9 +138,9 @@ func TestBadKvGet(t *testing.T) {
|
||||
"module": 1,
|
||||
"key": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestKVModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "kv.get module error: not a string",
|
||||
},
|
||||
{
|
||||
@@ -150,9 +149,9 @@ func TestBadKvGet(t *testing.T) {
|
||||
params: map[string]any{
|
||||
"module": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestKVModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "kv.get key error: not found",
|
||||
},
|
||||
{
|
||||
@@ -162,9 +161,9 @@ func TestBadKvGet(t *testing.T) {
|
||||
"module": "test",
|
||||
"key": 1,
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestKVModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "kv.get key error: not a string",
|
||||
},
|
||||
{
|
||||
@@ -174,8 +173,8 @@ func TestBadKvGet(t *testing.T) {
|
||||
"module": "test",
|
||||
"key": "test",
|
||||
},
|
||||
wrappedPayloadCtx: t.Context(),
|
||||
errorString: "kv.get wrapped payload has no modules",
|
||||
wrappedPayloadModules: nil,
|
||||
errorString: "kv.get wrapped payload has no modules",
|
||||
},
|
||||
{
|
||||
name: "module not found in context",
|
||||
@@ -184,8 +183,8 @@ func TestBadKvGet(t *testing.T) {
|
||||
"module": "test",
|
||||
"key": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{}),
|
||||
errorString: "kv.get unable to find module with id: test",
|
||||
wrappedPayloadModules: map[string]common.Module{},
|
||||
errorString: "kv.get unable to find module with id: test",
|
||||
},
|
||||
{
|
||||
name: "module not a kv module",
|
||||
@@ -194,9 +193,9 @@ func TestBadKvGet(t *testing.T) {
|
||||
"module": "test",
|
||||
"key": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "kv.get module with id test is not a KeyValueModule",
|
||||
},
|
||||
}
|
||||
@@ -221,7 +220,7 @@ func TestBadKvGet(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(test.wrappedPayloadCtx, test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Modules: test.wrappedPayloadModules, Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("kv.get expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package processor_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@@ -36,12 +35,12 @@ func TestKvSetFromRegistry(t *testing.T) {
|
||||
payload := ""
|
||||
expected := ""
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(test.GetContextWithModules(
|
||||
t.Context(),
|
||||
map[string]common.Module{
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
|
||||
Modules: map[string]common.Module{
|
||||
"test": &test.TestKVModule{},
|
||||
},
|
||||
), payload))
|
||||
Payload: payload,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("kv.set processing failed: %s", err)
|
||||
}
|
||||
@@ -86,12 +85,12 @@ func TestGoodKvSet(t *testing.T) {
|
||||
t.Fatalf("kv.set failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(test.GetContextWithModules(
|
||||
t.Context(),
|
||||
map[string]common.Module{
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
|
||||
Modules: map[string]common.Module{
|
||||
"test": &test.TestKVModule{},
|
||||
},
|
||||
), testCase.payload))
|
||||
Payload: testCase.payload,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("kv.set processing failed: %s", err)
|
||||
@@ -106,11 +105,11 @@ func TestGoodKvSet(t *testing.T) {
|
||||
|
||||
func TestBadKvSet(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
wrappedPayloadCtx context.Context
|
||||
errorString string
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
wrappedPayloadModules map[string]common.Module
|
||||
errorString string
|
||||
}{
|
||||
{
|
||||
name: "no module param",
|
||||
@@ -119,9 +118,9 @@ func TestBadKvSet(t *testing.T) {
|
||||
"key": "test",
|
||||
"value": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": &test.TestKVModule{},
|
||||
}),
|
||||
},
|
||||
errorString: "kv.set module error: not found",
|
||||
},
|
||||
{
|
||||
@@ -132,9 +131,9 @@ func TestBadKvSet(t *testing.T) {
|
||||
"key": "test",
|
||||
"value": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": &test.TestKVModule{},
|
||||
}),
|
||||
},
|
||||
errorString: "kv.set module error: not a string",
|
||||
},
|
||||
{
|
||||
@@ -144,9 +143,9 @@ func TestBadKvSet(t *testing.T) {
|
||||
"module": "test",
|
||||
"value": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": &test.TestKVModule{},
|
||||
}),
|
||||
},
|
||||
errorString: "kv.set key error: not found",
|
||||
},
|
||||
{
|
||||
@@ -157,9 +156,9 @@ func TestBadKvSet(t *testing.T) {
|
||||
"key": 1,
|
||||
"value": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": &test.TestKVModule{},
|
||||
}),
|
||||
},
|
||||
errorString: "kv.set key error: not a string",
|
||||
},
|
||||
{
|
||||
@@ -169,9 +168,9 @@ func TestBadKvSet(t *testing.T) {
|
||||
"module": "test",
|
||||
"key": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": &test.TestKVModule{},
|
||||
}),
|
||||
},
|
||||
errorString: "kv.set value error: not found",
|
||||
},
|
||||
{
|
||||
@@ -182,9 +181,9 @@ func TestBadKvSet(t *testing.T) {
|
||||
"key": "test",
|
||||
"value": 1,
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": &test.TestKVModule{},
|
||||
}),
|
||||
},
|
||||
errorString: "kv.set value error: not a string",
|
||||
},
|
||||
{
|
||||
@@ -195,8 +194,8 @@ func TestBadKvSet(t *testing.T) {
|
||||
"key": "test",
|
||||
"value": "hello",
|
||||
},
|
||||
wrappedPayloadCtx: t.Context(),
|
||||
errorString: "kv.set wrapped payload has no modules",
|
||||
wrappedPayloadModules: nil,
|
||||
errorString: "kv.set wrapped payload has no modules",
|
||||
},
|
||||
{
|
||||
name: "value template syntax error",
|
||||
@@ -206,9 +205,9 @@ func TestBadKvSet(t *testing.T) {
|
||||
"key": "test",
|
||||
"value": "{{",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": &test.TestKVModule{},
|
||||
}),
|
||||
},
|
||||
errorString: "template: template:1: unclosed action",
|
||||
},
|
||||
{
|
||||
@@ -219,9 +218,9 @@ func TestBadKvSet(t *testing.T) {
|
||||
"key": "test",
|
||||
"value": "{{.Data}}",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": &test.TestKVModule{},
|
||||
}),
|
||||
},
|
||||
errorString: "template: template:1:2: executing \"template\" at <.Data>: can't evaluate field Data in type common.WrappedPayload",
|
||||
},
|
||||
{
|
||||
@@ -232,8 +231,8 @@ func TestBadKvSet(t *testing.T) {
|
||||
"key": "test",
|
||||
"value": "hello",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{}),
|
||||
errorString: "kv.set unable to find module with id: test",
|
||||
wrappedPayloadModules: map[string]common.Module{},
|
||||
errorString: "kv.set unable to find module with id: test",
|
||||
},
|
||||
{
|
||||
name: "module not a kv module",
|
||||
@@ -243,9 +242,9 @@ func TestBadKvSet(t *testing.T) {
|
||||
"key": "test",
|
||||
"value": "hello",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "kv.set module with id test is not a KeyValueModule",
|
||||
},
|
||||
}
|
||||
@@ -270,7 +269,7 @@ func TestBadKvSet(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(testCase.wrappedPayloadCtx, testCase.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Modules: testCase.wrappedPayloadModules, Payload: testCase.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("kv.set expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -71,7 +71,7 @@ func TestGoodMIDIControlChangeCreate(t *testing.T) {
|
||||
t.Fatalf("midi.control_change.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("midi.control_change.create processing failed: %s", err)
|
||||
}
|
||||
@@ -147,7 +147,7 @@ func TestBadMIDIControlChangeCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("midi.control_change.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -45,7 +45,7 @@ func TestGoodMIDIMessageDecode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("midi.message.decode processing failed: %s", err)
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func TestBadMIDIMessageDecode(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("midi.message.decode expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -45,7 +45,7 @@ func TestGoodMIDIMessageEncode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := midiMessageEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := midiMessageEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("midi.message.encode processing failed: %s", err)
|
||||
}
|
||||
@@ -78,7 +78,7 @@ func TestBadMIDIMessageEncode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := midiMessageEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := midiMessageEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("midi.message.encode expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -85,7 +85,7 @@ func TestGoodMIDIMessageUnpack(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("midi.message.unpack processing failed: %s", err)
|
||||
}
|
||||
@@ -138,7 +138,7 @@ func TestBadMIDIMessageUnpack(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("midi.message.unpack expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -70,7 +70,7 @@ func TestGoodMIDINoteOffCretea(t *testing.T) {
|
||||
t.Fatalf("midi.note_off.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("midi.note_off.create processing failed: %s", err)
|
||||
}
|
||||
@@ -146,7 +146,7 @@ func TestBadMIDINoteOffCretea(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("midi.note_off.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -70,7 +70,7 @@ func TestGoodMIDINoteOnCreate(t *testing.T) {
|
||||
t.Fatalf("midi.note_on.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("midi.note_on.create processing failed: %s", err)
|
||||
}
|
||||
@@ -143,7 +143,7 @@ func TestBadMIDINoteOnCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("midi.note_on.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -69,7 +69,7 @@ func TestGoodMIDIProgramChangeCreate(t *testing.T) {
|
||||
t.Fatalf("midi.program_change.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("midi.program_change.create processing failed: %s", err)
|
||||
}
|
||||
@@ -133,7 +133,7 @@ func TestBadMIDIProgramChangeCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("midi.program_change.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -104,7 +104,7 @@ func TestGoodMQTTMessageCreate(t *testing.T) {
|
||||
t.Fatalf("mqtt.message.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("mqtt.message.create processing failed: %s", err)
|
||||
@@ -228,7 +228,7 @@ func TestBadMQTTMessageCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("mqtt.message.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -85,7 +85,7 @@ func TestGoodNATSMessageCreate(t *testing.T) {
|
||||
t.Fatalf("nats.message.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("nats.message.create processing failed: %s", err)
|
||||
}
|
||||
@@ -196,7 +196,7 @@ func TestBadNATSMessageCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("nats.message.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -160,7 +160,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
||||
t.Fatalf("osc.message.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("osc.message.create processing failed: %s", err)
|
||||
@@ -388,7 +388,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("osc.message.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -61,7 +61,7 @@ func TestGoodOSCMessageDecode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("osc.message.decode processing failed: %s", err)
|
||||
@@ -110,7 +110,7 @@ func TestBadOSCMessageDecode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("osc.message.decode expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -60,7 +60,7 @@ func TestGoodOSCMessageEncode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("osc.message.encode processing failed: %s", err)
|
||||
}
|
||||
@@ -101,7 +101,7 @@ func TestBadOSCMessageEncode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("osc.message.encode expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package processor_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@@ -35,7 +34,10 @@ func TestRouterOutputFromRegistry(t *testing.T) {
|
||||
payload := "test"
|
||||
expected := "test"
|
||||
|
||||
got, err := processorInstance.Process(test.GetContextWithRouter(t.Context()), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
|
||||
Router: test.GetNewTestRouter(),
|
||||
Payload: payload,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("router.output processing failed: %s", err)
|
||||
}
|
||||
@@ -71,7 +73,7 @@ func TestGoodRouterOutput(t *testing.T) {
|
||||
t.Fatalf("router.output failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(test.GetContextWithRouter(t.Context()), testCase.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: testCase.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("router.output processing failed: %s", err)
|
||||
}
|
||||
@@ -85,40 +87,37 @@ func TestGoodRouterOutput(t *testing.T) {
|
||||
|
||||
func TestBadRouterOutput(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
processCtx context.Context
|
||||
wrappedPayloadCtx context.Context
|
||||
errorString string
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
router common.RouteIO
|
||||
errorString string
|
||||
}{
|
||||
{
|
||||
name: "no module param",
|
||||
params: map[string]any{},
|
||||
payload: "test",
|
||||
processCtx: test.GetContextWithRouter(t.Context()),
|
||||
wrappedPayloadCtx: t.Context(),
|
||||
errorString: "router.output module error: not found",
|
||||
name: "no module param",
|
||||
params: map[string]any{},
|
||||
payload: "test",
|
||||
router: test.GetNewTestRouter(),
|
||||
errorString: "router.output module error: not found",
|
||||
},
|
||||
{
|
||||
name: "non-string module",
|
||||
params: map[string]any{
|
||||
"module": 123,
|
||||
},
|
||||
payload: "test",
|
||||
processCtx: test.GetContextWithRouter(t.Context()),
|
||||
wrappedPayloadCtx: t.Context(),
|
||||
errorString: "router.output module error: not a string",
|
||||
payload: "test",
|
||||
router: test.GetNewTestRouter(),
|
||||
|
||||
errorString: "router.output module error: not a string",
|
||||
},
|
||||
{
|
||||
name: "router not found in context",
|
||||
params: map[string]any{
|
||||
"module": "test",
|
||||
},
|
||||
payload: "test",
|
||||
processCtx: t.Context(),
|
||||
wrappedPayloadCtx: t.Context(),
|
||||
errorString: "router.output no router found",
|
||||
payload: "test",
|
||||
router: nil,
|
||||
errorString: "router.output no router found",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -142,7 +141,7 @@ func TestBadRouterOutput(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(testCase.processCtx, common.GetWrappedPayload(testCase.wrappedPayloadCtx, testCase.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Router: testCase.router, Payload: testCase.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("router.output expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package processor_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@@ -35,7 +34,10 @@ func TestRouterInputFromRegistry(t *testing.T) {
|
||||
payload := "test"
|
||||
expected := "test"
|
||||
|
||||
got, err := processorInstance.Process(test.GetContextWithRouter(t.Context()), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
|
||||
Router: test.GetNewTestRouter(),
|
||||
Payload: payload,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("router.input processing failed: %s", err)
|
||||
}
|
||||
@@ -71,7 +73,7 @@ func TestGoodRouterInput(t *testing.T) {
|
||||
t.Fatalf("router.input failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(test.GetContextWithRouter(t.Context()), testCase.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: testCase.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("router.input processing failed: %s", err)
|
||||
}
|
||||
@@ -85,40 +87,36 @@ func TestGoodRouterInput(t *testing.T) {
|
||||
|
||||
func TestBadRouterInput(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
processCtx context.Context
|
||||
wrappedPayloadCtx context.Context
|
||||
errorString string
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
router common.RouteIO
|
||||
errorString string
|
||||
}{
|
||||
{
|
||||
name: "no source param",
|
||||
params: map[string]any{},
|
||||
payload: "test",
|
||||
processCtx: test.GetContextWithRouter(t.Context()),
|
||||
wrappedPayloadCtx: t.Context(),
|
||||
errorString: "router.input source error: not found",
|
||||
name: "no source param",
|
||||
params: map[string]any{},
|
||||
payload: "test",
|
||||
router: test.GetNewTestRouter(),
|
||||
errorString: "router.input source error: not found",
|
||||
},
|
||||
{
|
||||
name: "non-string source",
|
||||
params: map[string]any{
|
||||
"source": 123,
|
||||
},
|
||||
payload: "test",
|
||||
processCtx: test.GetContextWithRouter(t.Context()),
|
||||
wrappedPayloadCtx: t.Context(),
|
||||
errorString: "router.input source error: not a string",
|
||||
payload: "test",
|
||||
router: test.GetNewTestRouter(),
|
||||
errorString: "router.input source error: not a string",
|
||||
},
|
||||
{
|
||||
name: "router not found in context",
|
||||
params: map[string]any{
|
||||
"source": "test",
|
||||
},
|
||||
payload: "test",
|
||||
processCtx: t.Context(),
|
||||
wrappedPayloadCtx: t.Context(),
|
||||
errorString: "router.input no router found",
|
||||
payload: "test",
|
||||
router: nil,
|
||||
errorString: "router.input no router found",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -142,7 +140,7 @@ func TestBadRouterInput(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(testCase.processCtx, common.GetWrappedPayload(testCase.wrappedPayloadCtx, testCase.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Router: testCase.router, Payload: testCase.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("router.input expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -76,7 +76,7 @@ func TestGoodScriptExpr(t *testing.T) {
|
||||
t.Fatalf("script.expr failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("script.expr processing failed: %s", err)
|
||||
@@ -134,7 +134,7 @@ func TestBadScriptExpr(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("script.expr expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -34,7 +34,7 @@ func TestScriptJSFromRegistry(t *testing.T) {
|
||||
payload := 1
|
||||
expected := 2
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("script.js processing failed: %s", err)
|
||||
}
|
||||
@@ -165,7 +165,7 @@ func TestGoodScriptJS(t *testing.T) {
|
||||
t.Fatalf("script.js failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("script.js processing failed: %s", err)
|
||||
@@ -209,7 +209,7 @@ func TestBadScriptJS(t *testing.T) {
|
||||
Params: test.params,
|
||||
})
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("script.js expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -73,7 +73,7 @@ func TestGoodScriptWASM(t *testing.T) {
|
||||
t.Fatalf("script.wasm failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("script.wasm processing failed: %s", err)
|
||||
@@ -176,7 +176,7 @@ func TestBadScriptWASM(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("script.wasm expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -90,7 +90,7 @@ func TestGoodSipResponseAudioCreate(t *testing.T) {
|
||||
t.Fatalf("sip.response.audio.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("sip.response.audio.create processing failed: %s", err)
|
||||
}
|
||||
@@ -200,7 +200,7 @@ func TestBadSipResponseAudioCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("sip.response.audio.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -88,7 +88,7 @@ func TestGoodSipResponseDTMFCreate(t *testing.T) {
|
||||
t.Fatalf("sip.response.dtmf.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("sip.response.dtmf.create processing failed: %s", err)
|
||||
}
|
||||
@@ -208,7 +208,7 @@ func TestBadSipResponseDTMFCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("sip.response.dtmf.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestStringCreateFromRegistry(t *testing.T) {
|
||||
payload := "hello"
|
||||
expected := "hello"
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("string.create processing failed: %s", err)
|
||||
}
|
||||
@@ -98,7 +98,7 @@ func TestGoodStringCreate(t *testing.T) {
|
||||
t.Fatalf("string.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("string.create processing failed: %s", err)
|
||||
@@ -174,7 +174,7 @@ func TestBadStringCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("string.create expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -28,7 +28,7 @@ func TestStringDecodeFromRegistry(t *testing.T) {
|
||||
payload := []byte{'h', 'e', 'l', 'l', 'o'}
|
||||
expected := "hello"
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("string.decode processing failed: %s", err)
|
||||
}
|
||||
@@ -54,7 +54,7 @@ func TestGoodStringDecode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := stringDecoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := stringDecoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("string.decode processing failed: %s", err)
|
||||
}
|
||||
@@ -87,7 +87,7 @@ func TestBadStringDecode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := stringDecoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := stringDecoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("string.decode expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestStringEncodeFromRegistry(t *testing.T) {
|
||||
payload := "hello"
|
||||
expected := []byte{'h', 'e', 'l', 'l', 'o'}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("string.encode processing failed: %s", err)
|
||||
}
|
||||
@@ -61,7 +61,7 @@ func TestGoodStringEncode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := stringEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := stringEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("string.encode processing failed: %s", err)
|
||||
}
|
||||
@@ -93,7 +93,7 @@ func TestBadStringEncode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := stringEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := stringEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("string.encode expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestStringSplitFromRegistry(t *testing.T) {
|
||||
payload := "part1,part2,part3"
|
||||
expected := []string{"part1", "part2", "part3"}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("string.split processing failed: %s", err)
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func TestGoodStringSplit(t *testing.T) {
|
||||
t.Fatalf("string.split failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("string.split processing failed: %s", err)
|
||||
}
|
||||
@@ -142,7 +142,7 @@ func TestBadStringSplit(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("string.split expected error but got none, payload: %+v", got)
|
||||
|
||||
@@ -33,7 +33,7 @@ func TestStructFieldGetFromRegistry(t *testing.T) {
|
||||
payload := test.TestStruct{Data: "hello"}
|
||||
expected := "hello"
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("struct.field.get processing failed: %s", err)
|
||||
}
|
||||
@@ -107,7 +107,7 @@ func TestGoodStructFieldGet(t *testing.T) {
|
||||
t.Fatalf("struct.field.get failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("struct.field.get processing failed: %s", err)
|
||||
@@ -179,7 +179,7 @@ func TestBadStructFieldGet(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("struct.field.get expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -33,7 +33,7 @@ func TestStructMethodGetFromRegistry(t *testing.T) {
|
||||
payload := test.TestStruct{Data: "hello"}
|
||||
expected := "hello"
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("struct.method.get processing failed: %s", err)
|
||||
}
|
||||
@@ -132,7 +132,7 @@ func TestGoodStructMethodGet(t *testing.T) {
|
||||
t.Fatalf("struct.method.get failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("struct.method.get processing failed: %s", err)
|
||||
@@ -204,7 +204,7 @@ func TestBadStructMethodGet(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("struct.method.get expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestGoodTimeSleep(t *testing.T) {
|
||||
t.Fatalf("time.sleep failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("time.sleep processing failed: %s", err)
|
||||
@@ -114,7 +114,7 @@ func TestBadTimeSleep(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("time.sleep expected to fail but succeeded, got: %v", got)
|
||||
|
||||
Reference in New Issue
Block a user