MCPcopy
hub / github.com/looplab/fsm / TestAsyncTransitionSpecificState

Function TestAsyncTransitionSpecificState

fsm_test.go:459–482  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

457}
458
459func TestAsyncTransitionSpecificState(t *testing.T) {
460 fsm := NewFSM(
461 "start",
462 Events{
463 {Name: "run", Src: []string{"start"}, Dst: "end"},
464 },
465 Callbacks{
466 "leave_start": func(_ context.Context, e *Event) {
467 e.Async()
468 },
469 },
470 )
471 _ = fsm.Event(context.Background(), "run")
472 if fsm.Current() != "start" {
473 t.Error("expected state to be 'start'")
474 }
475 err := fsm.Transition()
476 if err != nil {
477 t.Errorf("transition failed %v", err)
478 }
479 if fsm.Current() != "end" {
480 t.Error("expected state to be 'end'")
481 }
482}
483
484func TestAsyncTransitionInProgress(t *testing.T) {
485 fsm := NewFSM(

Callers

nothing calls this directly

Calls 6

EventMethod · 0.95
CurrentMethod · 0.95
TransitionMethod · 0.95
NewFSMFunction · 0.85
AsyncMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…