add test for loading from registry for rest of processors

This commit is contained in:
Joel Wetzell
2026-02-09 17:42:16 -06:00
parent f91cb9dbbf
commit 9dc4706fd8
25 changed files with 733 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestArtnetPacketCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["artnet.packet.decode"]
if !ok {
t.Fatalf("artnet.packet.decode processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "artnet.packet.decode",
})
if err != nil {
t.Fatalf("failed to decode artnet.packet.decode processor: %s", err)
}
if processorInstance.Type() != "artnet.packet.decode" {
t.Fatalf("artnet.packet.decode processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,27 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestArtnetPacketEncodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["artnet.packet.encode"]
if !ok {
t.Fatalf("artnet.packet.encode processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "artnet.packet.encode",
})
if err != nil {
t.Fatalf("failed to create artnet.packet.encode processor: %s", err)
}
if processorInstance.Type() != "artnet.packet.encode" {
t.Fatalf("artnet.packet.encode processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,38 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestFreeDCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["freed.create"]
if !ok {
t.Fatalf("freed.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "freed.create",
Params: map[string]any{
"id": "0",
"pan": "0",
"tilt": "0",
"roll": "0",
"posX": "0",
"posY": "0",
"posZ": "0",
"zoom": "0",
"focus": "0",
},
})
if err != nil {
t.Fatalf("failed to create freed.create processor: %s", err)
}
if processorInstance.Type() != "freed.create" {
t.Fatalf("freed.create processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,27 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestFreeDDecodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["freed.decode"]
if !ok {
t.Fatalf("freed.decode processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "freed.decode",
})
if err != nil {
t.Fatalf("failed to create freed.decode processor: %s", err)
}
if processorInstance.Type() != "freed.decode" {
t.Fatalf("freed.decode processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,27 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestFreeDEncodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["freed.encode"]
if !ok {
t.Fatalf("freed.encode processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "freed.encode",
})
if err != nil {
t.Fatalf("failed to create freed.encode processor: %s", err)
}
if processorInstance.Type() != "freed.encode" {
t.Fatalf("freed.encode processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,31 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestHTTPRequestCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["http.request.create"]
if !ok {
t.Fatalf("http.request.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "http.request.create",
Params: map[string]any{
"method": "GET",
"url": "http://example.com",
},
})
if err != nil {
t.Fatalf("failed to create http.request.create processor: %s", err)
}
if processorInstance.Type() != "http.request.create" {
t.Fatalf("http.request.create processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,27 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestHTTPRequestEncodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["http.request.encode"]
if !ok {
t.Fatalf("http.request.encode processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "http.request.encode",
})
if err != nil {
t.Fatalf("failed to create http.request.encode processor: %s", err)
}
if processorInstance.Type() != "http.request.encode" {
t.Fatalf("http.request.encode processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,31 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestHTTPRequestFilterFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["http.request.filter"]
if !ok {
t.Fatalf("http.request.filter processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "http.request.filter",
Params: map[string]any{
"method": "GET",
"path": "/test",
},
})
if err != nil {
t.Fatalf("failed to create http.request.filter processor: %s", err)
}
if processorInstance.Type() != "http.request.filter" {
t.Fatalf("http.request.filter processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,31 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestHTTPResponseCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["http.response.create"]
if !ok {
t.Fatalf("http.response.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "http.response.create",
Params: map[string]any{
"status": 200.0,
"bodyTemplate": "Hello, World!",
},
})
if err != nil {
t.Fatalf("failed to create http.response.create processor: %s", err)
}
if processorInstance.Type() != "http.response.create" {
t.Fatalf("http.response.create processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,27 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestHTTPResponseEncodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["http.response.encode"]
if !ok {
t.Fatalf("http.response.encode processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "http.response.encode",
})
if err != nil {
t.Fatalf("failed to create http.response.encode processor: %s", err)
}
if processorInstance.Type() != "http.response.encode" {
t.Fatalf("http.response.encode processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,33 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestMIDIMessageCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.message.create"]
if !ok {
t.Fatalf("midi.message.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "midi.message.create",
Params: map[string]any{
"type": "note_on",
"channel": "1",
"note": "60",
"velocity": "100",
},
})
if err != nil {
t.Fatalf("failed to create midi.message.create processor: %s", err)
}
if processorInstance.Type() != "midi.message.create" {
t.Fatalf("midi.message.create processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,27 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestMIDIMessageDecodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.message.decode"]
if !ok {
t.Fatalf("midi.message.decode processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "midi.message.decode",
})
if err != nil {
t.Fatalf("failed to create midi.message.decode processor: %s", err)
}
if processorInstance.Type() != "midi.message.decode" {
t.Fatalf("midi.message.decode processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,27 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestMIDIMessageEncodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.message.encode"]
if !ok {
t.Fatalf("midi.message.encode processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "midi.message.encode",
})
if err != nil {
t.Fatalf("failed to create midi.message.encode processor: %s", err)
}
if processorInstance.Type() != "midi.message.encode" {
t.Fatalf("midi.message.encode processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,30 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestMIDIMessageFilterFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.message.filter"]
if !ok {
t.Fatalf("midi.message.filter processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "midi.message.filter",
Params: map[string]any{
"type": "NoteOn",
},
})
if err != nil {
t.Fatalf("failed to create midi.message.filter processor: %s", err)
}
if processorInstance.Type() != "midi.message.filter" {
t.Fatalf("midi.message.filter processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,27 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestMIDIMessageUnpackFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["midi.message.unpack"]
if !ok {
t.Fatalf("midi.message.unpack processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "midi.message.unpack",
})
if err != nil {
t.Fatalf("failed to create midi.message.unpack processor: %s", err)
}
if processorInstance.Type() != "midi.message.unpack" {
t.Fatalf("midi.message.unpack processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,33 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestMQTTMessageCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["mqtt.message.create"]
if !ok {
t.Fatalf("mqtt.message.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "mqtt.message.create",
Params: map[string]any{
"topic": "test/topic",
"payload": "Hello, World!",
"qos": 1.0,
"retained": true,
},
})
if err != nil {
t.Fatalf("failed to create mqtt.message.create processor: %s", err)
}
if processorInstance.Type() != "mqtt.message.create" {
t.Fatalf("mqtt.message.create processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,27 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestMQTTMessageEncodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["mqtt.message.encode"]
if !ok {
t.Fatalf("mqtt.message.encode processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "mqtt.message.encode",
})
if err != nil {
t.Fatalf("failed to create mqtt.message.encode processor: %s", err)
}
if processorInstance.Type() != "mqtt.message.encode" {
t.Fatalf("mqtt.message.encode processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,31 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestNATSMessageCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["nats.message.create"]
if !ok {
t.Fatalf("nats.message.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "nats.message.create",
Params: map[string]any{
"subject": "test",
"payload": "Hello, World!",
},
})
if err != nil {
t.Fatalf("failed to create nats.message.create processor: %s", err)
}
if processorInstance.Type() != "nats.message.create" {
t.Fatalf("nats.message.create processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,27 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestNATSMessageEncodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["nats.message.encode"]
if !ok {
t.Fatalf("nats.message.encode processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "nats.message.encode",
})
if err != nil {
t.Fatalf("failed to create nats.message.encode processor: %s", err)
}
if processorInstance.Type() != "nats.message.encode" {
t.Fatalf("nats.message.encode processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,30 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestOSCMessageCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["osc.message.create"]
if !ok {
t.Fatalf("osc.message.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "osc.message.create",
Params: map[string]any{
"address": "/test",
},
})
if err != nil {
t.Fatalf("failed to create osc.message.create processor: %s", err)
}
if processorInstance.Type() != "osc.message.create" {
t.Fatalf("osc.message.create processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,27 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestOSCMessageDecodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["osc.message.decode"]
if !ok {
t.Fatalf("osc.message.decode processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "osc.message.decode",
})
if err != nil {
t.Fatalf("failed to create osc.message.decode processor: %s", err)
}
if processorInstance.Type() != "osc.message.decode" {
t.Fatalf("osc.message.decode processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,27 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestOSCMessageEncodeFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["osc.message.encode"]
if !ok {
t.Fatalf("osc.message.encode processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "osc.message.encode",
})
if err != nil {
t.Fatalf("failed to create osc.message.encode processor: %s", err)
}
if processorInstance.Type() != "osc.message.encode" {
t.Fatalf("osc.message.encode processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,30 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestOSCMessageFilterFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["osc.message.filter"]
if !ok {
t.Fatalf("osc.message.filter processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "osc.message.filter",
Params: map[string]any{
"address": "/test*",
},
})
if err != nil {
t.Fatalf("failed to filter osc.message.filter processor: %s", err)
}
if processorInstance.Type() != "osc.message.filter" {
t.Fatalf("osc.message.filter processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,32 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestSipResponseAudioCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["sip.response.audio.create"]
if !ok {
t.Fatalf("sip.response.audio.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "sip.response.audio.create",
Params: map[string]any{
"preWait": 0.0,
"audioFile": "good.wav",
"postWait": 0.0,
},
})
if err != nil {
t.Fatalf("failed to filter sip.response.audio.create processor: %s", err)
}
if processorInstance.Type() != "sip.response.audio.create" {
t.Fatalf("sip.response.audio.create processor has wrong type: %s", processorInstance.Type())
}
}

View File

@@ -0,0 +1,32 @@
package processor_test
import (
"testing"
"github.com/jwetzell/showbridge-go/internal/config"
"github.com/jwetzell/showbridge-go/internal/processor"
)
func TestSipResponseDTMFCreateFromRegistry(t *testing.T) {
registration, ok := processor.ProcessorRegistry["sip.response.dtmf.create"]
if !ok {
t.Fatalf("sip.response.dtmf.create processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "sip.response.dtmf.create",
Params: map[string]any{
"preWait": 0.0,
"digits": "good.wav",
"postWait": 0.0,
},
})
if err != nil {
t.Fatalf("failed to filter sip.response.dtmf.create processor: %s", err)
}
if processorInstance.Type() != "sip.response.dtmf.create" {
t.Fatalf("sip.response.dtmf.create processor has wrong type: %s", processorInstance.Type())
}
}