mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-08-22 22:38:58 +00:00
add constructor for test module type
This commit is contained in:
@@ -19,7 +19,7 @@ func TestModuleBadRegistrationNoType(t *testing.T) {
|
||||
module.RegisterModule(module.ModuleRegistration{
|
||||
Type: "",
|
||||
New: func(config config.ModuleConfig) (common.Module, error) {
|
||||
return &test.TestModule{}, nil
|
||||
return test.NewTestModule("test"), nil
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -47,14 +47,14 @@ func TestModuleBadRegistrationExistingType(t *testing.T) {
|
||||
module.RegisterModule(module.ModuleRegistration{
|
||||
Type: "module.test",
|
||||
New: func(config config.ModuleConfig) (common.Module, error) {
|
||||
return &test.TestModule{}, nil
|
||||
return test.NewTestModule("test"), nil
|
||||
},
|
||||
})
|
||||
|
||||
module.RegisterModule(module.ModuleRegistration{
|
||||
Type: "module.test",
|
||||
New: func(config config.ModuleConfig) (common.Module, error) {
|
||||
return &test.TestModule{}, nil
|
||||
return test.NewTestModule("test"), nil
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ func TestBadModuleOutput(t *testing.T) {
|
||||
name: "no module param",
|
||||
params: map[string]any{},
|
||||
payload: "test",
|
||||
modules: map[string]common.Module{"test": &test.TestModule{}},
|
||||
modules: map[string]common.Module{"test": test.NewTestModule("test")},
|
||||
errorString: "module.output module error: not found",
|
||||
},
|
||||
{
|
||||
@@ -107,7 +107,7 @@ func TestBadModuleOutput(t *testing.T) {
|
||||
"module": 123,
|
||||
},
|
||||
payload: "test",
|
||||
modules: map[string]common.Module{"test": &test.TestModule{}},
|
||||
modules: map[string]common.Module{"test": test.NewTestModule("test")},
|
||||
errorString: "module.output module error: not a string",
|
||||
},
|
||||
{
|
||||
|
||||
@@ -8,7 +8,14 @@ import (
|
||||
_ "modernc.org/sqlite"
|
||||
)
|
||||
|
||||
func NewTestModule(id string) *TestModule {
|
||||
return &TestModule{
|
||||
id: id,
|
||||
}
|
||||
}
|
||||
|
||||
type TestModule struct {
|
||||
id string
|
||||
}
|
||||
|
||||
func (m *TestModule) Start(ctx context.Context, router common.RouteIO) error {
|
||||
|
||||
Reference in New Issue
Block a user