options_test.go
This file
Path
options_test.go
106 lines · 2.5 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–4why, one step back1package tea23import (4 "bytes"chore: merge pull request #1376 from desertwitch/stacked-patchesAyman Bagabasbefore adoption915f65d
line 5why, one step back5 "context"feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
lines 6–12why, one step back6 "os"7 "sync/atomic"8 "testing"9)1011func TestOptions(t *testing.T) {12 t.Run("output", func(t *testing.T) {fix: prevent data race with cursedRenderer.onMouse (#1691)Liam Stanleybefore adoptionc60f0c5
line 13why, one step back13 t.Parallel()feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
lines 14–21why, one step back14 var b bytes.Buffer15 p := NewProgram(nil, WithOutput(&b))16 if f, ok := p.output.(*os.File); ok {17 t.Errorf("expected output to custom, got %v", f.Fd())18 }19 })2021 t.Run("renderer", func(t *testing.T) {fix: prevent data race with cursedRenderer.onMouse (#1691)Liam Stanleybefore adoptionc60f0c5
line 22why, one step back22 t.Parallel()feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
line 23why, one step back23 p := NewProgram(nil, WithoutRenderer())Merge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97
line 24why, one step back24 if !p.disableRenderer {feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
lines 25–29why, one step back25 t.Errorf("expected renderer to be a nilRenderer, got %v", p.renderer)26 }27 })2829 t.Run("without signals", func(t *testing.T) {fix: prevent data race with cursedRenderer.onMouse (#1691)Liam Stanleybefore adoptionc60f0c5
line 30why, one step back30 t.Parallel()feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
lines 31–37why, one step back31 p := NewProgram(nil, WithoutSignals())32 if atomic.LoadUint32(&p.ignoreSignals) == 0 {33 t.Errorf("ignore signals should have been set")34 }35 })3637 t.Run("filter", func(t *testing.T) {fix: prevent data race with cursedRenderer.onMouse (#1691)Liam Stanleybefore adoptionc60f0c5
line 38why, one step back38 t.Parallel()feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
lines 39–41why, one step back39 p := NewProgram(nil, WithFilter(func(_ Model, msg Msg) Msg { return msg }))40 if p.filter == nil {41 t.Errorf("expected filter to be set")chore: merge pull request #1376 from desertwitch/stacked-patchesAyman Bagabasbefore adoption915f65d
lines 42–45why, one step back42 }43 })4445 t.Run("external context", func(t *testing.T) {fix: prevent data race with cursedRenderer.onMouse (#1691)Liam Stanleybefore adoptionc60f0c5
line 46why, one step back46 t.Parallel()chore: merge pull request #1376 from desertwitch/stacked-patchesAyman Bagabasbefore adoption915f65d
lines 47–51why, one step back47 extCtx, extCancel := context.WithCancel(context.Background())48 defer extCancel()4950 p := NewProgram(nil, WithContext(extCtx))51 if p.externalCtx != extCtx || p.externalCtx == context.Background() {Merge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97
line 52why, one step back52 t.Errorf("expected passed in external context, got default")feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
lines 53–56why, one step back53 }54 })5556 t.Run("input options", func(t *testing.T) {Merge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97
line 57why, one step back57 exercise := func(t *testing.T, opt ProgramOption, fn func(*Program)) {feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
line 58why, one step back58 p := NewProgram(nil, opt)Merge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97
line 59why, one step back59 fn(p)feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
lines 60–61why, one step back60 }61Merge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97
line 62why, one step back62 t.Run("nil input", func(t *testing.T) {fix: prevent data race with cursedRenderer.onMouse (#1691)Liam Stanleybefore adoptionc60f0c5
line 63why, one step back63 t.Parallel()Merge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97
lines 64–68why, one step back64 exercise(t, WithInput(nil), func(p *Program) {65 if !p.disableInput || p.input != nil {66 t.Errorf("expected input to be disabled, got %v", p.input)67 }68 })feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
lines 69–71why, one step back69 })7071 t.Run("custom input", func(t *testing.T) {fix: prevent data race with cursedRenderer.onMouse (#1691)Liam Stanleybefore adoptionc60f0c5
line 72why, one step back72 t.Parallel()feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
line 73why, one step back73 var b bytes.BufferMerge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97
lines 74–78why, one step back74 exercise(t, WithInput(&b), func(p *Program) {75 if p.input != &b {76 t.Errorf("expected input to be custom, got %v", p.input)77 }78 })feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
lines 79–82why, one step back79 })80 })8182 t.Run("startup options", func(t *testing.T) {Merge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97
line 83why, one step back83 exercise := func(t *testing.T, opt ProgramOption, fn func(*Program)) {feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
line 84why, one step back84 p := NewProgram(nil, opt)Merge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97
line 85why, one step back85 fn(p)feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
lines 86–88why, one step back86 }8788 t.Run("without catch panics", func(t *testing.T) {fix: prevent data race with cursedRenderer.onMouse (#1691)Liam Stanleybefore adoptionc60f0c5
line 89why, one step back89 t.Parallel()Merge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97
lines 90–94why, one step back90 exercise(t, WithoutCatchPanics(), func(p *Program) {91 if !p.disableCatchPanics {92 t.Errorf("expected catch panics to be disabled")93 }94 })feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
lines 95–97why, one step back95 })9697 t.Run("without signal handler", func(t *testing.T) {fix: prevent data race with cursedRenderer.onMouse (#1691)Liam Stanleybefore adoptionc60f0c5
line 98why, one step back98 t.Parallel()Merge pull request #1118 from charmbracelet/v2-expAyman Bagabasbefore adoptiond1c8c97
lines 99–103why, one step back99 exercise(t, WithoutSignalHandler(), func(p *Program) {100 if !p.disableSignalHandler {101 t.Errorf("expected signal handler to be disabled")102 }103 })feat(render): skipping lines from previous frameKonstantin Antonovbefore adoption3dfbcd9
lines 104–106why, one step back104 })105 })106}