commands_test.go
This file
Path
commands_test.go
67 lines · 1.4 KiB · Go
Last changed by
fix: prevent data race with cursedRenderer.onMouse (#1691)Liam Stanleybefore adoptionc60f0c5
History of this fileTake it
The walk stopped after 200 commits: lines older than 3dfbcd9 point at it.
feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
lines 1–8why, one step back1package tea23import (4 "testing"5 "time"6)78func TestEvery(t *testing.T) {fix: prevent data race with cursedRenderer.onMouse (#1691)Liam Stanleybefore adoptionc60f0c5
line 9why, one step back9 t.Parallel()feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
lines 10–19why, one step back10 expected := "every ms"11 msg := Every(time.Millisecond, func(t time.Time) Msg {12 return expected13 })()14 if expected != msg {15 t.Fatalf("expected a msg %v but got %v", expected, msg)16 }17}1819func TestTick(t *testing.T) {fix: prevent data race with cursedRenderer.onMouse (#1691)Liam Stanleybefore adoptionc60f0c5
line 20why, one step back20 t.Parallel()feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
lines 21–30why, one step back21 expected := "tick"22 msg := Tick(time.Millisecond, func(t time.Time) Msg {23 return expected24 })()25 if expected != msg {26 t.Fatalf("expected a msg %v but got %v", expected, msg)27 }28}2930func TestBatch(t *testing.T) {fix: prevent data race with cursedRenderer.onMouse (#1691)Liam Stanleybefore adoptionc60f0c5
line 31why, one step back31 t.Parallel()fix: compact sequences like batches (#958)Joe Henkebefore adoptionc76509a
lines 32–35why, one step back32 testMultipleCommands[BatchMsg](t, Batch)33}3435func TestSequence(t *testing.T) {fix: prevent data race with cursedRenderer.onMouse (#1691)Liam Stanleybefore adoptionc60f0c5
line 36why, one step back36 t.Parallel()fix: compact sequences like batches (#958)Joe Henkebefore adoptionc76509a
lines 37–40why, one step back37 testMultipleCommands[sequenceMsg](t, Sequence)38}3940func testMultipleCommands[T ~[]Cmd](t *testing.T, createFn func(cmd ...Cmd) Cmd) {feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
line 41why, one step back41 t.Run("nil cmd", func(t *testing.T) {fix: prevent data race with cursedRenderer.onMouse (#1691)Liam Stanleybefore adoptionc60f0c5
line 42why, one step back42 t.Parallel()fix: compact sequences like batches (#958)Joe Henkebefore adoptionc76509a
line 43why, one step back43 if b := createFn(nil); b != nil {feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
lines 44–47why, one step back44 t.Fatalf("expected nil, got %+v", b)45 }46 })47 t.Run("empty cmd", func(t *testing.T) {fix: prevent data race with cursedRenderer.onMouse (#1691)Liam Stanleybefore adoptionc60f0c5
line 48why, one step back48 t.Parallel()fix: compact sequences like batches (#958)Joe Henkebefore adoptionc76509a
line 49why, one step back49 if b := createFn(); b != nil {feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
lines 50–53why, one step back50 t.Fatalf("expected nil, got %+v", b)51 }52 })53 t.Run("single cmd", func(t *testing.T) {fix: prevent data race with cursedRenderer.onMouse (#1691)Liam Stanleybefore adoptionc60f0c5
line 54why, one step back54 t.Parallel()fix: compact sequences like batches (#958)Joe Henkebefore adoptionc76509a
line 55why, one step back55 b := createFn(Quit)()feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
lines 56–60why, one step back56 if _, ok := b.(QuitMsg); !ok {57 t.Fatalf("expected a QuitMsg, got %T", b)58 }59 })60 t.Run("mixed nil cmds", func(t *testing.T) {fix: prevent data race with cursedRenderer.onMouse (#1691)Liam Stanleybefore adoptionc60f0c5
line 61why, one step back61 t.Parallel()fix: compact sequences like batches (#958)Joe Henkebefore adoptionc76509a
lines 62–63why, one step back62 b := createFn(nil, Quit, nil, Quit, nil, nil)()63 if l := len(b.(T)); l != 2 {feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
lines 64–67why, one step back64 t.Fatalf("expected a []Cmd with len 2, got %d", l)65 }66 })67}