mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-27 13:25:40 +00:00
add test for loading from registry for all modules
This commit is contained in:
32
internal/module/test/mqtt-client_test.go
Normal file
32
internal/module/test/mqtt-client_test.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package module_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/jwetzell/showbridge-go/internal/config"
|
||||
"github.com/jwetzell/showbridge-go/internal/module"
|
||||
)
|
||||
|
||||
func TestMQTTClientFromRegistry(t *testing.T) {
|
||||
registration, ok := module.ModuleRegistry["mqtt.client"]
|
||||
if !ok {
|
||||
t.Fatalf("mqtt.client module not registered")
|
||||
}
|
||||
|
||||
moduleInstance, err := registration.New(config.ModuleConfig{
|
||||
Type: "mqtt.client",
|
||||
Params: map[string]any{
|
||||
"broker": "mqtt://localhost:1883",
|
||||
"topic": "test/topic",
|
||||
"clientId": "test",
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create mqtt.client module: %s", err)
|
||||
}
|
||||
|
||||
if moduleInstance.Type() != "mqtt.client" {
|
||||
t.Fatalf("mqtt.client module has wrong type: %s", moduleInstance.Type())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user