MCPcopy Create free account
hub / github.com/anchordotdev/cli / TestPanic

Function TestPanic

cli_test.go:109–140  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

107}
108
109func TestPanic(t *testing.T) {
110 setupCleanup(t)
111
112 ctx, cancel := context.WithCancel(context.Background())
113 defer cancel()
114
115 ctx = cli.ContextWithConfig(ctx, &cli.Config{
116 NonInteractive: true,
117 Test: cli.ConfigTest{
118 Browserless: true,
119 Timestamp: Timestamp,
120 },
121 })
122
123 t.Run(fmt.Sprintf("golden-%s", uitest.TestTagOS()), func(t *testing.T) {
124 drv, tm := uitest.TestTUI(ctx, t)
125
126 cmd := PanicCommand{}
127 err := stacktrace.CapturePanic(func() error { return cmd.UI().RunTUI(ctx, drv) })
128
129 if want, got := "test panic", err.Error(); want != got {
130 t.Fatalf("want return err %q, got %q", want, got)
131 }
132
133 cli.ReportError(ctx, err, drv, CmdError, nil)
134
135 drv.Program.Quit()
136
137 tm.WaitFinished(t, teatest.WithFinalTimeout(time.Second*3))
138 uitest.TestGolden(t, drv.Golden())
139 })
140}
141
142type TestHeader struct {
143 Type string

Callers

nothing calls this directly

Calls 13

UIMethod · 0.95
ContextWithConfigFunction · 0.92
TestTagOSFunction · 0.92
TestTUIFunction · 0.92
CapturePanicFunction · 0.92
ReportErrorFunction · 0.92
TestGoldenFunction · 0.92
setupCleanupFunction · 0.85
GoldenMethod · 0.80
RunMethod · 0.65
QuitMethod · 0.65
RunTUIMethod · 0.45

Tested by

no test coverage detected