@@ -75,16 +75,17 @@ func Test_Combine_OptStopTogether(t *testing.T) {
7575 }
7676}
7777
78- func Test_Combine_OptOnStop (t * testing.T ) {
78+ func Test_Combine_OptOnStopOptOnStart (t * testing.T ) {
7979 t .Parallel ()
8080
8181 const actorsCount = 5
8282
83+ onStatC , onStartOpt := createCombinedOnStartOption (t , 1 )
8384 onStopC , onStopOpt := createCombinedOnStopOption (t , 1 )
8485 actors := createActors (actorsCount )
8586
8687 a := Combine (actors ... ).
87- WithOptions (onStopOpt ).
88+ WithOptions (onStopOpt , onStartOpt ).
8889 Build ()
8990
9091 a .Start ()
@@ -94,6 +95,7 @@ func Test_Combine_OptOnStop(t *testing.T) {
9495 a .Stop () // should have no effect
9596 a .Stop () // should have no effect
9697 assert .Equal (t , `🌚` , <- onStopC )
98+ assert .Equal (t , `🌞` , <- onStatC )
9799}
98100
99101func Test_Combine_OptOnStop_AfterActorStops (t * testing.T ) {
@@ -143,14 +145,29 @@ func createActor(i int, opts ...Option) Actor {
143145func createCombinedOnStopOption (t * testing.T , count int ) (<- chan any , CombinedOption ) {
144146 t .Helper ()
145147
146- onStopC := make (chan any , count )
147- onStopFunc := func () {
148+ c := make (chan any , count )
149+ fn := func () {
148150 select {
149- case onStopC <- `🌚` :
151+ case c <- `🌚` :
150152 default :
151153 t .Fatal ("onStopFunc should be called only once" )
152154 }
153155 }
154156
155- return onStopC , OptOnStopCombined (onStopFunc )
157+ return c , OptOnStopCombined (fn )
158+ }
159+
160+ func createCombinedOnStartOption (t * testing.T , count int ) (<- chan any , CombinedOption ) {
161+ t .Helper ()
162+
163+ c := make (chan any , count )
164+ fn := func (_ Context ) {
165+ select {
166+ case c <- `🌞` :
167+ default :
168+ t .Fatal ("onStart should be called only once" )
169+ }
170+ }
171+
172+ return c , OptOnStartCombined (fn )
156173}
0 commit comments