mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-08-30 10:18:58 +00:00
add test for route id
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
func TestRouteCreate(t *testing.T) {
|
||||
routeConfig := config.RouteConfig{
|
||||
Id: "test-route",
|
||||
Input: "input",
|
||||
}
|
||||
|
||||
@@ -21,6 +22,10 @@ func TestRouteCreate(t *testing.T) {
|
||||
t.Fatalf("route failed to create: %v", err)
|
||||
}
|
||||
|
||||
if testRoute.Id() != routeConfig.Id {
|
||||
t.Fatalf("route id does not match expected id")
|
||||
}
|
||||
|
||||
if testRoute.Input() != routeConfig.Input {
|
||||
t.Fatalf("route input does not match expected input")
|
||||
}
|
||||
@@ -54,9 +59,9 @@ func TestGoodRouteHandleInput(t *testing.T) {
|
||||
inputData := "test input data"
|
||||
testRouter := test.GetNewTestRouter()
|
||||
payload, err := testRoute.ProcessPayload(t.Context(), common.WrappedPayload{
|
||||
InputHandler: testRouter.HandleInput,
|
||||
Modules: map[string]common.Module{"output": &test.TestOutputModule{}},
|
||||
Payload: inputData,
|
||||
InputHandler: testRouter.HandleInput,
|
||||
Modules: map[string]common.Module{"output": &test.TestOutputModule{}},
|
||||
Payload: inputData,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("route ProcessPayload returned error: %v", err)
|
||||
@@ -94,9 +99,9 @@ func TestRouteHandleInputWithProcessorError(t *testing.T) {
|
||||
inputData := "test input data"
|
||||
testRouter := test.GetNewTestRouter()
|
||||
_, err = testRoute.ProcessPayload(t.Context(), common.WrappedPayload{
|
||||
InputHandler: testRouter.HandleInput,
|
||||
Modules: map[string]common.Module{"output": &test.TestOutputModule{}},
|
||||
Payload: inputData,
|
||||
InputHandler: testRouter.HandleInput,
|
||||
Modules: map[string]common.Module{"output": &test.TestOutputModule{}},
|
||||
Payload: inputData,
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatalf("route did not return error for bad processor")
|
||||
@@ -124,9 +129,9 @@ func TestRouteHandleNilPayload(t *testing.T) {
|
||||
|
||||
testRouter := test.GetNewTestRouter()
|
||||
payload, err := testRoute.ProcessPayload(t.Context(), common.WrappedPayload{
|
||||
InputHandler: testRouter.HandleInput,
|
||||
Modules: map[string]common.Module{"output": &test.TestOutputModule{}},
|
||||
Payload: nil,
|
||||
InputHandler: testRouter.HandleInput,
|
||||
Modules: map[string]common.Module{"output": &test.TestOutputModule{}},
|
||||
Payload: nil,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("route ProcessPayload returned error: %v", err)
|
||||
@@ -157,9 +162,9 @@ func TestRouteHandleNilPayloadFromProcessor(t *testing.T) {
|
||||
|
||||
testRouter := test.GetNewTestRouter()
|
||||
_, err = testRoute.ProcessPayload(t.Context(), common.WrappedPayload{
|
||||
InputHandler: testRouter.HandleInput,
|
||||
Modules: map[string]common.Module{"output": &test.TestOutputModule{}},
|
||||
Payload: "test",
|
||||
InputHandler: testRouter.HandleInput,
|
||||
Modules: map[string]common.Module{"output": &test.TestOutputModule{}},
|
||||
Payload: "test",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("route returned error for nil payload: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user