(t *testing.T)
| 398 | } |
| 399 | |
| 400 | func TestTeaBatchMsg(t *testing.T) { |
| 401 | t.Parallel() |
| 402 | var buf bytes.Buffer |
| 403 | var in bytes.Buffer |
| 404 | |
| 405 | inc := func() Msg { |
| 406 | return incrementMsg{} |
| 407 | } |
| 408 | |
| 409 | m := &testModel{} |
| 410 | p := NewProgram(m, |
| 411 | WithInput(&in), |
| 412 | WithOutput(&buf), |
| 413 | ) |
| 414 | go func() { |
| 415 | p.Send(BatchMsg{inc, inc}) |
| 416 | |
| 417 | for { |
| 418 | time.Sleep(time.Millisecond) |
| 419 | i := m.counter.Load() |
| 420 | if i != nil && i.(int) >= 2 { |
| 421 | p.Quit() |
| 422 | return |
| 423 | } |
| 424 | } |
| 425 | }() |
| 426 | |
| 427 | if _, err := p.Run(); err != nil { |
| 428 | t.Fatal(err) |
| 429 | } |
| 430 | |
| 431 | if m.counter.Load() != 2 { |
| 432 | t.Fatalf("counter should be 2, got %d", m.counter.Load()) |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | func TestTeaSequenceMsg(t *testing.T) { |
| 437 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…