mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-09-10 15:39:25 +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{
|
module.RegisterModule(module.ModuleRegistration{
|
||||||
Type: "",
|
Type: "",
|
||||||
New: func(config config.ModuleConfig) (common.Module, error) {
|
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{
|
module.RegisterModule(module.ModuleRegistration{
|
||||||
Type: "module.test",
|
Type: "module.test",
|
||||||
New: func(config config.ModuleConfig) (common.Module, error) {
|
New: func(config config.ModuleConfig) (common.Module, error) {
|
||||||
return &test.TestModule{}, nil
|
return test.NewTestModule("test"), nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
module.RegisterModule(module.ModuleRegistration{
|
module.RegisterModule(module.ModuleRegistration{
|
||||||
Type: "module.test",
|
Type: "module.test",
|
||||||
New: func(config config.ModuleConfig) (common.Module, error) {
|
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",
|
name: "no module param",
|
||||||
params: map[string]any{},
|
params: map[string]any{},
|
||||||
payload: "test",
|
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",
|
errorString: "module.output module error: not found",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -107,7 +107,7 @@ func TestBadModuleOutput(t *testing.T) {
|
|||||||
"module": 123,
|
"module": 123,
|
||||||
},
|
},
|
||||||
payload: "test",
|
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",
|
errorString: "module.output module error: not a string",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,14 @@ import (
|
|||||||
_ "modernc.org/sqlite"
|
_ "modernc.org/sqlite"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func NewTestModule(id string) *TestModule {
|
||||||
|
return &TestModule{
|
||||||
|
id: id,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type TestModule struct {
|
type TestModule struct {
|
||||||
|
id string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *TestModule) Start(ctx context.Context, router common.RouteIO) error {
|
func (m *TestModule) Start(ctx context.Context, router common.RouteIO) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user