Skip to content

Commit

Permalink
simplify some asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
qmuntal committed Jul 13, 2023
1 parent 8042590 commit 635795e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
8 changes: 3 additions & 5 deletions statemachine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,9 @@ func TestStateMachine_PermittedTriggers_PermittedTriggersAreDistinctValues(t *te

permitted, _ := sm.PermittedTriggers(context.Background())

if got := len(permitted); got != 1 {
t.Fatalf("PermittedTriggers() = %v, want %v", got, 1)
}
if got := permitted[0]; got != triggerX {
t.Errorf("PermittedTriggers() = %v, want %v", got, triggerX)
want := []any{triggerX}
if !reflect.DeepEqual(permitted, want) {
t.Errorf("PermittedTriggers() = %v, want %v", permitted, want)
}
}

Expand Down
22 changes: 6 additions & 16 deletions states_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,9 @@ func Test_stateRepresentation_Enter_ActionsExecuteInOrder(t *testing.T) {
})
transition := Transition{Source: stateA, Destination: stateB, Trigger: triggerX}
sr.Enter(context.Background(), transition)
if got := len(actual); got != 2 {
t.Fatalf("expected 2 actions to be executed, got %d", got)
}
if got := actual[0]; got != 0 {
t.Errorf("expected action 0 to be executed first, got %d", got)
}
if got := actual[1]; got != 1 {
t.Errorf("expected action 1 to be executed second, got %d", got)
want := []int{0, 1}
if !reflect.DeepEqual(actual, want) {
t.Errorf("expected %v, got %v", want, actual)
}
}

Expand Down Expand Up @@ -466,14 +461,9 @@ func Test_stateRepresentation_Exit_ActionsExecuteInOrder(t *testing.T) {
})
transition := Transition{Source: stateB, Destination: stateC, Trigger: triggerX}
sr.Exit(context.Background(), transition)
if got := len(actual); got != 2 {
t.Fatalf("expected 2 actions to be executed, got %d", got)
}
if got := actual[0]; got != 0 {
t.Errorf("expected action 0 to be executed first, got %d", got)
}
if got := actual[1]; got != 1 {
t.Errorf("expected action 1 to be executed second, got %d", got)
want := []int{0, 1}
if !reflect.DeepEqual(actual, want) {
t.Errorf("expected %v, got %v", want, actual)
}
}

Expand Down

0 comments on commit 635795e

Please sign in to comment.