Skip to content

Commit f93c675

Browse files
authored
Merge pull request #9885 from ffranr/sm-isrunning-unit-test
protofsm: exercise `StateMachine.IsRunning()` in unit test
2 parents 5a036a8 + 828e764 commit f93c675

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

protofsm/state_machine_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,26 @@ func TestStateMachineDaemonEvents(t *testing.T) {
357357
}
358358
stateMachine := NewStateMachine(cfg)
359359

360+
// Before we start up the state machine, we'll assert that the machine
361+
// is not running.
362+
require.False(t, stateMachine.IsRunning())
363+
360364
// As we're triggering internal events, we'll also subscribe to the set
361365
// of new states so we can assert as we go.
362366
stateSub := stateMachine.RegisterStateEvents()
363367
defer stateMachine.RemoveStateSub(stateSub)
364368

365369
stateMachine.Start(ctx)
366-
defer stateMachine.Stop()
370+
defer func() {
371+
stateMachine.Stop()
372+
373+
// After we stop the state machine, we expect it to no longer be
374+
// running.
375+
require.False(t, stateMachine.IsRunning())
376+
}()
377+
378+
// The state machine should now be running.
379+
require.True(t, stateMachine.IsRunning())
367380

368381
// As soon as we send in the daemon event, we expect the
369382
// disable+broadcast events to be processed, as they are unconditional.

0 commit comments

Comments
 (0)