From 6bc64a3e5b9fd93658e45e963eef3a8cdefa6c9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Sterba?= <andre.sterba@stud.h-da.de> Date: Fri, 1 Jul 2022 09:27:21 +0200 Subject: [PATCH] Adjust tests --- controller/api/initialise_test.go | 2 +- .../routingTableService_test.go | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/controller/api/initialise_test.go b/controller/api/initialise_test.go index 70d84dc97..1e8e02578 100644 --- a/controller/api/initialise_test.go +++ b/controller/api/initialise_test.go @@ -151,7 +151,7 @@ func bootstrapUnitTest() { jwtManager := rbacImpl.NewJWTManager("", (10000 * time.Hour)) nodeStore := store.NewGenericStore[nodes.Node]() - nodeService := nodes.NewNodeService(nodeStore) + nodeService := nodes.NewNodeService(nodeStore, eventService) portStore := store.NewGenericStore[ports.Port]() portService := ports.NewPortService(portStore) diff --git a/controller/topology/routing-tables/routingTableService_test.go b/controller/topology/routing-tables/routingTableService_test.go index 55fd7a19f..b815946d3 100644 --- a/controller/topology/routing-tables/routingTableService_test.go +++ b/controller/topology/routing-tables/routingTableService_test.go @@ -4,6 +4,7 @@ import ( "reflect" "testing" + eventservice "code.fbi.h-da.de/danet/gosdn/controller/eventService" "code.fbi.h-da.de/danet/gosdn/controller/topology/nodes" "code.fbi.h-da.de/danet/gosdn/controller/topology/ports" "code.fbi.h-da.de/danet/gosdn/controller/topology/store" @@ -95,12 +96,12 @@ func TestNewRoutingTableService(t *testing.T) { name: "should create a new topology service", args: args{ store: getTestStoreWithRoutingTables(t, []RoutingTable{}), - nodeService: nodes.NewNodeService(getTestStoreWithNodes(t, []nodes.Node{})), + nodeService: nodes.NewNodeService(getTestStoreWithNodes(t, []nodes.Node{}), eventservice.NewMockEventService()), portService: ports.NewPortService(getTestStoreWithPorts(t, []ports.Port{})), }, want: NewRoutingTableService( getTestStoreWithRoutingTables(t, []RoutingTable{}), - nodes.NewNodeService(getTestStoreWithNodes(t, []nodes.Node{})), + nodes.NewNodeService(getTestStoreWithNodes(t, []nodes.Node{}), eventservice.NewMockEventService()), ports.NewPortService(getTestStoreWithPorts(t, []ports.Port{})), ), }, @@ -137,7 +138,7 @@ func TestTopologyService_EnsureExists(t *testing.T) { nodeService: nodes.NewNodeService(getTestStoreWithNodes( t, []nodes.Node{}, - )), + ), eventservice.NewMockEventService()), portService: ports.NewPortService(getTestStoreWithPorts( t, []ports.Port{}, @@ -156,7 +157,7 @@ func TestTopologyService_EnsureExists(t *testing.T) { nodeService: nodes.NewNodeService(getTestStoreWithNodes( t, []nodes.Node{getTestNode()}, - )), + ), eventservice.NewMockEventService()), portService: ports.NewPortService(getTestStoreWithPorts( t, []ports.Port{getTestPort()}, @@ -208,7 +209,7 @@ func TestRoutingTableService_Update(t *testing.T) { name: "should update an existing routing table", fields: fields{ store: getTestStoreWithRoutingTables(t, []RoutingTable{getTestRoutingTable()}), - nodeService: nodes.NewNodeService(getTestStoreWithNodes(t, []nodes.Node{})), + nodeService: nodes.NewNodeService(getTestStoreWithNodes(t, []nodes.Node{}), eventservice.NewMockEventService()), portService: ports.NewPortService(getTestStoreWithPorts(t, []ports.Port{})), }, args: args{ @@ -252,7 +253,7 @@ func TestRoutingTableService_Delete(t *testing.T) { name: "should delete an existing routing table", fields: fields{ store: getTestStoreWithRoutingTables(t, []RoutingTable{getTestRoutingTable()}), - nodeService: nodes.NewNodeService(getTestStoreWithNodes(t, []nodes.Node{})), + nodeService: nodes.NewNodeService(getTestStoreWithNodes(t, []nodes.Node{}), eventservice.NewMockEventService()), portService: ports.NewPortService(getTestStoreWithPorts(t, []ports.Port{})), }, args: args{ @@ -264,7 +265,7 @@ func TestRoutingTableService_Delete(t *testing.T) { name: "should fail if a routing table does not exists", fields: fields{ store: store.NewGenericStore[RoutingTable](), - nodeService: nodes.NewNodeService(getTestStoreWithNodes(t, []nodes.Node{})), + nodeService: nodes.NewNodeService(getTestStoreWithNodes(t, []nodes.Node{}), eventservice.NewMockEventService()), portService: ports.NewPortService(getTestStoreWithPorts(t, []ports.Port{})), }, args: args{ @@ -307,7 +308,7 @@ func TestRoutingTableService_Get(t *testing.T) { name: "should error if routing table with uuid is not in store", fields: fields{ store: getTestStoreWithRoutingTables(t, []RoutingTable{}), - nodeService: nodes.NewNodeService(getTestStoreWithNodes(t, []nodes.Node{})), + nodeService: nodes.NewNodeService(getTestStoreWithNodes(t, []nodes.Node{}), eventservice.NewMockEventService()), portService: ports.NewPortService(getTestStoreWithPorts(t, []ports.Port{})), }, args: args{ @@ -367,7 +368,7 @@ func TestRoutingTableService_GetAll(t *testing.T) { name: "should get all stored routing tables", fields: fields{ store: getTestStoreWithRoutingTables(t, []RoutingTable{getTestRoutingTable()}), - nodeService: nodes.NewNodeService(getTestStoreWithNodes(t, []nodes.Node{})), + nodeService: nodes.NewNodeService(getTestStoreWithNodes(t, []nodes.Node{}), eventservice.NewMockEventService()), portService: ports.NewPortService(getTestStoreWithPorts(t, []ports.Port{})), }, want: []RoutingTable{getTestRoutingTable()}, -- GitLab