Skip to content

Commit

Permalink
test: add sequenceMsg test
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Oct 8, 2022
1 parent 9117bbc commit 77619d2
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tea_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,27 @@ func TestTeaBatchMsg(t *testing.T) {
}

if m.counter.Load() != 2 {
t.Fatalf("counter should be 2, got %d", m.counter)
t.Fatalf("counter should be 2, got %d", m.counter.Load())
}
}

func TestTeaSequenceMsg(t *testing.T) {
var buf bytes.Buffer
var in bytes.Buffer

inc := func() Msg {
return incrementMsg{}
}

m := &testModel{}
p := NewProgram(m, WithInput(&in), WithOutput(&buf))
go p.Send(sequenceMsg{inc, inc, Quit})

if _, err := p.Run(); err != nil {
t.Fatal(err)
}

if m.counter.Load() != 2 {
t.Fatalf("counter should be 2, got %d", m.counter.Load())
}
}

0 comments on commit 77619d2

Please sign in to comment.