We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 437d063 commit 1a74970Copy full SHA for 1a74970
pkg/modules/stopper/stopper_test.go
@@ -0,0 +1,32 @@
1
+package stopper
2
+
3
+import (
4
+ "context"
5
+ "github.com/stretchr/testify/assert"
6
+ "testing"
7
+)
8
9
+func TestStopperCallsStop(t *testing.T) {
10
+ stopWasCalled := false
11
12
+ var stopFunc context.CancelFunc = func() {
13
+ stopWasCalled = true
14
+ }
15
16
+ ctx, cancel := context.WithCancel(context.Background())
17
+ defer cancel()
18
19
+ stopperModule := NewModule(stopFunc)
20
+ stopperModule.Start(ctx)
21
22
+ stopperInput, err := stopperModule.Input(InputName)
23
+ assert.NoError(t, err)
24
25
+ // Act: send stop signal to stopper
26
+ stopperInput.Push(struct{}{})
27
28
+ err = stopperModule.Close()
29
30
31
+ assert.True(t, stopWasCalled, "stop was never called")
32
+}
0 commit comments