mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-27 13:25:40 +00:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
100edab869 | ||
|
|
fd4c2cb59b | ||
|
|
b6ee3c68f1 | ||
|
|
7e0c2b2560 | ||
|
|
c9a3eb80bc | ||
|
|
2a5feec07a | ||
|
|
ced4bc839e | ||
|
|
ce6a9ff4a8 | ||
|
|
bd3b8a19d5 | ||
|
|
cb738a9b8e | ||
|
|
1b59dbc1e5 | ||
|
|
c75a2327d5 | ||
|
|
a17be985e6 | ||
|
|
78737f57af | ||
|
|
720c0cd52a | ||
|
|
3e1d4f07f9 | ||
|
|
452e308f8f | ||
|
|
d16d833520 | ||
|
|
f203b32261 | ||
|
|
361c4f4499 | ||
|
|
a76d12d799 | ||
|
|
7d91e64ec4 | ||
|
|
589c59c693 |
6
.github/labeler.yml
vendored
6
.github/labeler.yml
vendored
@@ -14,10 +14,14 @@ processor:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: 'internal/processor/**'
|
||||
|
||||
router:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: 'router*'
|
||||
|
||||
route:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: 'internal/route/**'
|
||||
|
||||
|
||||
cli:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: 'cmd/showbridge/**'
|
||||
|
||||
5
.github/release.yml
vendored
5
.github/release.yml
vendored
@@ -17,12 +17,13 @@ changelog:
|
||||
- title: Processor 🏭
|
||||
labels:
|
||||
- processor
|
||||
- title: Route 🛣️
|
||||
- title: Routing 🛣️
|
||||
labels:
|
||||
- router
|
||||
- route
|
||||
- title: CLI ⌨️
|
||||
labels:
|
||||
- cmd
|
||||
- cli
|
||||
- title: Other Changes
|
||||
labels:
|
||||
- '*'
|
||||
2
.github/workflows/release-showbridge.yaml
vendored
2
.github/workflows/release-showbridge.yaml
vendored
@@ -43,7 +43,7 @@ jobs:
|
||||
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
|
||||
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
10
go.mod
10
go.mod
@@ -4,16 +4,16 @@ go 1.25.5
|
||||
|
||||
require (
|
||||
github.com/eclipse/paho.mqtt.golang v1.5.1
|
||||
github.com/emiago/diago v0.24.0
|
||||
github.com/emiago/sipgo v1.1.0
|
||||
github.com/emiago/diago v0.26.2
|
||||
github.com/emiago/sipgo v1.1.2
|
||||
github.com/expr-lang/expr v1.17.7
|
||||
github.com/extism/go-sdk v1.7.1
|
||||
github.com/jwetzell/artnet-go v0.1.0
|
||||
github.com/jwetzell/artnet-go v0.2.1
|
||||
github.com/jwetzell/free-d-go v0.1.0
|
||||
github.com/jwetzell/osc-go v0.1.0
|
||||
github.com/jwetzell/psn-go v0.3.0
|
||||
github.com/nats-io/nats.go v1.48.0
|
||||
github.com/urfave/cli/v3 v3.6.1
|
||||
github.com/urfave/cli/v3 v3.6.2
|
||||
gitlab.com/gomidi/midi/v2 v2.3.18
|
||||
go.bug.st/serial v1.6.4
|
||||
modernc.org/quickjs v0.17.1
|
||||
@@ -24,6 +24,7 @@ require (
|
||||
github.com/creack/goselect v0.1.2 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/dylibso/observe-sdk/go v0.0.0-20240819160327-2d926c5d788a // indirect
|
||||
github.com/emiago/dtls/v3 v3.0.0-20260122183559-8b8d23e359c0 // indirect
|
||||
github.com/go-audio/riff v1.0.0 // indirect
|
||||
github.com/gobwas/glob v0.2.3 // indirect
|
||||
github.com/gobwas/httphead v0.1.0 // indirect
|
||||
@@ -44,6 +45,7 @@ require (
|
||||
github.com/pion/rtp v1.8.26 // indirect
|
||||
github.com/pion/srtp/v3 v3.0.9 // indirect
|
||||
github.com/pion/transport/v3 v3.1.1 // indirect
|
||||
github.com/pion/transport/v4 v4.0.1 // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
github.com/tetratelabs/wabin v0.0.0-20230304001439-f6f874872834 // indirect
|
||||
github.com/tetratelabs/wazero v1.9.0 // indirect
|
||||
|
||||
20
go.sum
20
go.sum
@@ -8,10 +8,12 @@ github.com/dylibso/observe-sdk/go v0.0.0-20240819160327-2d926c5d788a h1:UwSIFv5g
|
||||
github.com/dylibso/observe-sdk/go v0.0.0-20240819160327-2d926c5d788a/go.mod h1:C8DzXehI4zAbrdlbtOByKX6pfivJTBiV9Jjqv56Yd9Q=
|
||||
github.com/eclipse/paho.mqtt.golang v1.5.1 h1:/VSOv3oDLlpqR2Epjn1Q7b2bSTplJIeV2ISgCl2W7nE=
|
||||
github.com/eclipse/paho.mqtt.golang v1.5.1/go.mod h1:1/yJCneuyOoCOzKSsOTUc0AJfpsItBGWvYpBLimhArU=
|
||||
github.com/emiago/diago v0.24.0 h1:NJ94m/h04SPIDet9x19IZoMDss+fRJ58HHqUqfHI4GY=
|
||||
github.com/emiago/diago v0.24.0/go.mod h1:MwO7aQbGtgOdfm0Soj6XqEfAcskstixiS9gnxMV9xeo=
|
||||
github.com/emiago/sipgo v1.1.0 h1:ryr9DhoDercbyCmCtGiZD/uB1NY745DZpsUHfSbWWaI=
|
||||
github.com/emiago/sipgo v1.1.0/go.mod h1:DuwAxBZhKMqIzQFPGZb1MVAGU6Wuxj64oTOhd5dx/FY=
|
||||
github.com/emiago/diago v0.26.2 h1:3QL03V0drX96eIBFBpfueNcywydRgYqffKihluGL0gA=
|
||||
github.com/emiago/diago v0.26.2/go.mod h1:jZ+7EnKcmgqKnLjCHPqfbP4Y/9Q/JLSLxMflDrp2J1M=
|
||||
github.com/emiago/dtls/v3 v3.0.0-20260122183559-8b8d23e359c0 h1:o4LxpUnZ1zxiQ+Qjc9kLwXcjz31NGAHmnZ7xoJto3VM=
|
||||
github.com/emiago/dtls/v3 v3.0.0-20260122183559-8b8d23e359c0/go.mod h1:ydcZ977eS1I6uOWodzMuw30BwvNAzT9su/xcNYSJqjA=
|
||||
github.com/emiago/sipgo v1.1.2 h1:JvLqEvqNSQm2mBX40qZ7O0WC3Ee67Z0UrfmBI7y6Beo=
|
||||
github.com/emiago/sipgo v1.1.2/go.mod h1:DuwAxBZhKMqIzQFPGZb1MVAGU6Wuxj64oTOhd5dx/FY=
|
||||
github.com/expr-lang/expr v1.17.7 h1:Q0xY/e/2aCIp8g9s/LGvMDCC5PxYlvHgDZRQ4y16JX8=
|
||||
github.com/expr-lang/expr v1.17.7/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4=
|
||||
github.com/extism/go-sdk v1.7.1 h1:lWJos6uY+tRFdlIHR+SJjwFDApY7OypS/2nMhiVQ9Sw=
|
||||
@@ -38,8 +40,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20240805132620-81f5be970eca h1:T54Ema1
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20240805132620-81f5be970eca/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw=
|
||||
github.com/icholy/digest v1.1.0 h1:HfGg9Irj7i+IX1o1QAmPfIBNu/Q5A5Tu3n/MED9k9H4=
|
||||
github.com/icholy/digest v1.1.0/go.mod h1:QNrsSGQ5v7v9cReDI0+eyjsXGUoRSUZQHeQ5C4XLa0Y=
|
||||
github.com/jwetzell/artnet-go v0.1.0 h1:cW2BUkEwLMMMsYSlvGhDtE3ZTgYpvjnRy/OYLPNPk1U=
|
||||
github.com/jwetzell/artnet-go v0.1.0/go.mod h1:gli97Z32a0kMkZ6taoTiK7/lqHcF/dhiGjGJdx/PxqA=
|
||||
github.com/jwetzell/artnet-go v0.2.1 h1:iYTKWcwYrF5kBkYfkw2UbWvoueeA23iKEn7fR27mWZE=
|
||||
github.com/jwetzell/artnet-go v0.2.1/go.mod h1:gli97Z32a0kMkZ6taoTiK7/lqHcF/dhiGjGJdx/PxqA=
|
||||
github.com/jwetzell/free-d-go v0.1.0 h1:xHt6dvyit98X+OC3jVzV0aLidxbyzi3vI9QiYkteEtA=
|
||||
github.com/jwetzell/free-d-go v0.1.0/go.mod h1:KmrkooRARRaxJTBSPvwt/6IMAIaHH1R8bSA8cwbbELw=
|
||||
github.com/jwetzell/osc-go v0.1.0 h1:EXxup5VWBErHot2Ri4MFToPf6KCzLDTbCt2x6GLfw8I=
|
||||
@@ -74,6 +76,8 @@ github.com/pion/srtp/v3 v3.0.9 h1:lRGF4G61xxj+m/YluB3ZnBpiALSri2lTzba0kGZMrQY=
|
||||
github.com/pion/srtp/v3 v3.0.9/go.mod h1:E+AuWd7Ug2Fp5u38MKnhduvpVkveXJX6J4Lq4rxUYt8=
|
||||
github.com/pion/transport/v3 v3.1.1 h1:Tr684+fnnKlhPceU+ICdrw6KKkTms+5qHMgw6bIkYOM=
|
||||
github.com/pion/transport/v3 v3.1.1/go.mod h1:+c2eewC5WJQHiAA46fkMMzoYZSuGzA/7E2FPrOYHctQ=
|
||||
github.com/pion/transport/v4 v4.0.1 h1:sdROELU6BZ63Ab7FrOLn13M6YdJLY20wldXW2Cu2k8o=
|
||||
github.com/pion/transport/v4 v4.0.1/go.mod h1:nEuEA4AD5lPdcIegQDpVLgNoDGreqM/YqmEx3ovP4jM=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||
@@ -86,8 +90,8 @@ github.com/tetratelabs/wabin v0.0.0-20230304001439-f6f874872834 h1:ZF+QBjOI+tILZ
|
||||
github.com/tetratelabs/wabin v0.0.0-20230304001439-f6f874872834/go.mod h1:m9ymHTgNSEjuxvw8E7WWe4Pl4hZQHXONY8wE6dMLaRk=
|
||||
github.com/tetratelabs/wazero v1.9.0 h1:IcZ56OuxrtaEz8UYNRHBrUa9bYeX9oVY93KspZZBf/I=
|
||||
github.com/tetratelabs/wazero v1.9.0/go.mod h1:TSbcXCfFP0L2FGkRPxHphadXPjo1T6W+CseNNY7EkjM=
|
||||
github.com/urfave/cli/v3 v3.6.1 h1:j8Qq8NyUawj/7rTYdBGrxcH7A/j7/G8Q5LhWEW4G3Mo=
|
||||
github.com/urfave/cli/v3 v3.6.1/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso=
|
||||
github.com/urfave/cli/v3 v3.6.2 h1:lQuqiPrZ1cIz8hz+HcrG0TNZFxU70dPZ3Yl+pSrH9A8=
|
||||
github.com/urfave/cli/v3 v3.6.2/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso=
|
||||
github.com/zaf/g711 v1.4.0 h1:XZYkjjiAg9QTBnHqEg37m2I9q3IIDv5JRYXs2N8ma7c=
|
||||
github.com/zaf/g711 v1.4.0/go.mod h1:eCDXt3dSp/kYYAoooba7ukD/Q75jvAaS4WOMr0l1Roo=
|
||||
gitlab.com/gomidi/midi/v2 v2.3.18 h1:sj2fOhtvOe+zI8YJe8qTxLw5zv0ntULLUDwcFOaZQbI=
|
||||
|
||||
@@ -89,6 +89,7 @@ func (pc *PSNClient) Run(ctx context.Context) error {
|
||||
}
|
||||
|
||||
if pc.router != nil {
|
||||
// TODO(jwetzell): better input handling
|
||||
for _, tracker := range pc.decoder.Trackers {
|
||||
pc.router.HandleInput(pc.ctx, pc.Id(), tracker)
|
||||
}
|
||||
|
||||
@@ -43,20 +43,19 @@ func init() {
|
||||
return nil, errors.New("serial.client port must be a string")
|
||||
}
|
||||
|
||||
framingMethod := "RAW"
|
||||
framingMethod, ok := params["framing"]
|
||||
|
||||
framingMethodRaw, ok := params["framing"]
|
||||
|
||||
if ok {
|
||||
framingMethodString, ok := framingMethodRaw.(string)
|
||||
|
||||
if !ok {
|
||||
return nil, errors.New("serial.client framing method must be a string")
|
||||
}
|
||||
framingMethod = framingMethodString
|
||||
if !ok {
|
||||
return nil, errors.New("serial.client requires a framing parameter")
|
||||
}
|
||||
|
||||
framer := framer.GetFramer(framingMethod)
|
||||
framingMethodString, ok := framingMethod.(string)
|
||||
|
||||
if !ok {
|
||||
return nil, errors.New("serial.client framing method must be a string")
|
||||
}
|
||||
|
||||
framer := framer.GetFramer(framingMethodString)
|
||||
|
||||
if framer == nil {
|
||||
return nil, fmt.Errorf("serial.client unknown framing method: %s", framingMethod)
|
||||
|
||||
@@ -56,20 +56,19 @@ func init() {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
framingMethod := "RAW"
|
||||
framingMethod, ok := params["framing"]
|
||||
|
||||
framingMethodRaw, ok := params["framing"]
|
||||
|
||||
if ok {
|
||||
framingMethodString, ok := framingMethodRaw.(string)
|
||||
|
||||
if !ok {
|
||||
return nil, errors.New("net.tcp.client framing method must be a string")
|
||||
}
|
||||
framingMethod = framingMethodString
|
||||
if !ok {
|
||||
return nil, errors.New("net.tcp.client requires a framing parameter")
|
||||
}
|
||||
|
||||
framer := framer.GetFramer(framingMethod)
|
||||
framingMethodString, ok := framingMethod.(string)
|
||||
|
||||
if !ok {
|
||||
return nil, errors.New("net.tcp.client framing method must be a string")
|
||||
}
|
||||
|
||||
framer := framer.GetFramer(framingMethodString)
|
||||
|
||||
if framer == nil {
|
||||
return nil, fmt.Errorf("net.tcp.client unknown framing method: %s", framingMethod)
|
||||
|
||||
@@ -45,20 +45,19 @@ func init() {
|
||||
return nil, errors.New("net.tcp.server port must be a number")
|
||||
}
|
||||
|
||||
framingMethod := "RAW"
|
||||
framingMethod, ok := params["framing"]
|
||||
|
||||
framingMethodRaw, ok := params["framing"]
|
||||
|
||||
if ok {
|
||||
framingMethodString, ok := framingMethodRaw.(string)
|
||||
|
||||
if !ok {
|
||||
return nil, errors.New("net.tcp.server framing method must be a string")
|
||||
}
|
||||
framingMethod = framingMethodString
|
||||
if !ok {
|
||||
return nil, errors.New("net.tcp.server requires a framing parameter")
|
||||
}
|
||||
|
||||
framer := framer.GetFramer(framingMethod)
|
||||
framingMethodString, ok := framingMethod.(string)
|
||||
|
||||
if !ok {
|
||||
return nil, errors.New("net.tcp.server framing method must be a string")
|
||||
}
|
||||
|
||||
framer := framer.GetFramer(framingMethodString)
|
||||
|
||||
if framer == nil {
|
||||
return nil, fmt.Errorf("net.tcp.server unknown framing method: %s", framingMethod)
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
"text/template"
|
||||
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
"github.com/jwetzell/showbridge-go/internal/processor"
|
||||
)
|
||||
|
||||
@@ -15,6 +16,39 @@ func (t TestStruct) GetData() string {
|
||||
return t.Data
|
||||
}
|
||||
|
||||
func TestStringCreateFromRegistry(t *testing.T) {
|
||||
registration, ok := processor.ProcessorRegistry["string.create"]
|
||||
if !ok {
|
||||
t.Fatalf("string.create processor not registered")
|
||||
}
|
||||
|
||||
processorInstance, err := registration.New(config.ProcessorConfig{
|
||||
Type: "string.create",
|
||||
Params: map[string]any{
|
||||
"template": "{{.}}",
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create string.create processor: %s", err)
|
||||
}
|
||||
|
||||
if processorInstance.Type() != "string.create" {
|
||||
t.Fatalf("string.create processor has wrong type: %s", processorInstance.Type())
|
||||
}
|
||||
|
||||
payload := "hello"
|
||||
expected := "hello"
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), payload)
|
||||
if err != nil {
|
||||
t.Fatalf("string.create processing failed: %s", err)
|
||||
}
|
||||
|
||||
if got != expected {
|
||||
t.Fatalf("string.create got %+v, expected %+v", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGoodStringCreate(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
@@ -79,3 +113,75 @@ func TestGoodStringCreate(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBadStringCreate(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
errorString string
|
||||
}{
|
||||
{
|
||||
name: "no template param",
|
||||
payload: "hello",
|
||||
params: map[string]any{},
|
||||
errorString: "string.create requires a template parameter",
|
||||
},
|
||||
{
|
||||
name: "non string template",
|
||||
payload: "hello",
|
||||
params: map[string]any{
|
||||
"template": 1,
|
||||
},
|
||||
errorString: "string.create template must be a string",
|
||||
},
|
||||
{
|
||||
name: "invalid template",
|
||||
payload: "hello",
|
||||
params: map[string]any{
|
||||
"template": "{{.",
|
||||
},
|
||||
errorString: "template: template:1: illegal number syntax: \".\"",
|
||||
},
|
||||
{
|
||||
name: "bad property in template",
|
||||
payload: "hello",
|
||||
params: map[string]any{
|
||||
"template": "{{.Invalid}}",
|
||||
},
|
||||
errorString: "template: template:1:2: executing \"template\" at <.Invalid>: can't evaluate field Invalid in type string",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
registration, ok := processor.ProcessorRegistry["string.create"]
|
||||
if !ok {
|
||||
t.Fatalf("string.create processor not registered")
|
||||
}
|
||||
|
||||
processorInstance, err := registration.New(config.ProcessorConfig{
|
||||
Type: "string.create",
|
||||
Params: test.params,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
if test.errorString != err.Error() {
|
||||
t.Fatalf("string.encode got error '%s', expected '%s'", err.Error(), test.errorString)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), test.payload)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("string.encode expected to fail but got payload: %s", got)
|
||||
}
|
||||
|
||||
if err.Error() != test.errorString {
|
||||
t.Fatalf("string.encode got error '%s', expected '%s'", err.Error(), test.errorString)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,40 @@ package processor_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
"github.com/jwetzell/showbridge-go/internal/processor"
|
||||
)
|
||||
|
||||
func TestStringDecodeFromRegistry(t *testing.T) {
|
||||
registration, ok := processor.ProcessorRegistry["string.decode"]
|
||||
if !ok {
|
||||
t.Fatalf("string.decode processor not registered")
|
||||
}
|
||||
|
||||
processorInstance, err := registration.New(config.ProcessorConfig{
|
||||
Type: "string.decode",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create string.decode processor: %s", err)
|
||||
}
|
||||
|
||||
if processorInstance.Type() != "string.decode" {
|
||||
t.Fatalf("string.decode processor has wrong type: %s", processorInstance.Type())
|
||||
}
|
||||
|
||||
payload := []byte{'h', 'e', 'l', 'l', 'o'}
|
||||
expected := "hello"
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), payload)
|
||||
if err != nil {
|
||||
t.Fatalf("string.decode processing failed: %s", err)
|
||||
}
|
||||
|
||||
if got != expected {
|
||||
t.Fatalf("string.decode got %+v, expected %+v", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGoodStringDecode(t *testing.T) {
|
||||
stringDecoder := processor.StringDecode{}
|
||||
tests := []struct {
|
||||
|
||||
@@ -4,9 +4,46 @@ import (
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
"github.com/jwetzell/showbridge-go/internal/processor"
|
||||
)
|
||||
|
||||
func TestStringEncodeFromRegistry(t *testing.T) {
|
||||
registration, ok := processor.ProcessorRegistry["string.encode"]
|
||||
if !ok {
|
||||
t.Fatalf("string.encode processor not registered")
|
||||
}
|
||||
|
||||
processorInstance, err := registration.New(config.ProcessorConfig{
|
||||
Type: "string.encode",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create string.encode processor: %s", err)
|
||||
}
|
||||
|
||||
if processorInstance.Type() != "string.encode" {
|
||||
t.Fatalf("string.encode processor has wrong type: %s", processorInstance.Type())
|
||||
}
|
||||
|
||||
payload := "hello"
|
||||
expected := []byte{'h', 'e', 'l', 'l', 'o'}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), payload)
|
||||
if err != nil {
|
||||
t.Fatalf("string.encode processing failed: %s", err)
|
||||
}
|
||||
|
||||
gotBytes, ok := got.([]byte)
|
||||
|
||||
if !ok {
|
||||
t.Fatalf("string.encode should return byte slice")
|
||||
}
|
||||
|
||||
if !slices.Equal(gotBytes, expected) {
|
||||
t.Fatalf("string.encode got %+v, expected %+v", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGoodStringEncode(t *testing.T) {
|
||||
stringEncoder := processor.StringEncode{}
|
||||
tests := []struct {
|
||||
|
||||
12
router.go
12
router.go
@@ -34,6 +34,18 @@ func NewRouter(config config.Config) (*Router, []module.ModuleError, []route.Rou
|
||||
|
||||
for moduleIndex, moduleDecl := range config.Modules {
|
||||
|
||||
if moduleDecl.Id == "" {
|
||||
if moduleErrors == nil {
|
||||
moduleErrors = []module.ModuleError{}
|
||||
}
|
||||
moduleErrors = append(moduleErrors, module.ModuleError{
|
||||
Index: moduleIndex,
|
||||
Config: moduleDecl,
|
||||
Error: errors.New("module id cannot be empty"),
|
||||
})
|
||||
continue
|
||||
}
|
||||
|
||||
moduleInfo, ok := module.ModuleRegistry[moduleDecl.Type]
|
||||
if !ok {
|
||||
if moduleErrors == nil {
|
||||
|
||||
Reference in New Issue
Block a user