@@ -17,19 +17,20 @@ import (
1717func TestShutDownServer (t * testing.T ) {
1818 ctx , cancel := context .WithCancel (context .Background ())
1919 defer cancel ()
20- mockSvc := & mockService {}
21- mockServices := services .New (mockSvc )
2220 mockKafka := & mockKafkaClient {}
21+
2322 kp := publisher .NewKafkaFromClient (mockKafka , 50 , "test" )
2423
2524 shutdownCh := make (chan bool , 1 )
2625 bufferCh := make (chan collection.CollectRequest , 1 )
2726
27+ services := services .Create (bufferCh , ctx )
28+
2829 wp := worker .CreateWorkerPool (1 , bufferCh , 1 , kp )
2930
3031 // run shutdown in background
3132 sigCh := make (chan os.Signal , 1 )
32- go shutDownServer (ctx , cancel , mockServices , bufferCh , wp , kp , shutdownCh , sigCh )
33+ go shutDownServer (ctx , cancel , services , bufferCh , wp , kp , shutdownCh , sigCh )
3334
3435 // send a termination signal after short delay
3536 go func () {
@@ -44,11 +45,8 @@ func TestShutDownServer(t *testing.T) {
4445 t .Error ("shutdown execution failed" )
4546 }
4647
47- if ! mockSvc .shutdownCalled {
48- t .Errorf ("expected httpServices.Shutdown to be called" )
49- }
5048 if ! isClosed (bufferCh ) {
51- t .Errorf ("expected shutdown channel to be closed" )
49+ t .Errorf ("expected buffer channel to be closed" )
5250 }
5351 if ! mockKafka .FlushCalled {
5452 t .Errorf ("expected Kafka.FlushCalled to be called" )
@@ -68,24 +66,6 @@ func isClosed(ch <-chan collection.CollectRequest) bool {
6866}
6967
7068// ---- Mocks ----
71- // mockKafkaClient is a mock for the Client interface
72- type mockService struct {
73- shutdownCalled bool
74- }
75-
76- func (m * mockService ) Init (context.Context ) error {
77- return nil
78- }
79-
80- func (* mockService ) Name () string {
81- return "mock server"
82- }
83-
84- func (m * mockService ) Shutdown (ctx context.Context ) error {
85- m .shutdownCalled = true
86- return nil
87- }
88-
8969// mockKafkaClient is a mock for the Client interface
9070type mockKafkaClient struct {
9171 // Tracking flags
0 commit comments