MCPcopy Index your code
hub / github.com/anchordotdev/cli / TestError

Function TestError

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

Source from the content-addressed store, hash-verified

60}
61
62func TestError(t *testing.T) {
63 setupCleanup(t)
64
65 ctx, cancel := context.WithCancel(context.Background())
66 defer cancel()
67
68 ctx = cli.ContextWithConfig(ctx, &cli.Config{
69 NonInteractive: true,
70 Test: cli.ConfigTest{
71 Browserless: true,
72 Timestamp: Timestamp,
73 },
74 })
75
76 t.Run(fmt.Sprintf("golden-%s", uitest.TestTagOS()), func(t *testing.T) {
77 drv, tm := uitest.TestTUI(ctx, t)
78
79 cmd := ErrorCommand{}
80 err := stacktrace.CapturePanic(func() error { return cmd.UI().RunTUI(ctx, drv) })
81
82 if want, got := testErr, err; !reflect.DeepEqual(want, got) {
83 t.Fatalf("want return err %+v, got %+v", want, got)
84 }
85
86 cli.ReportError(ctx, err, drv, CmdError, nil)
87
88 drv.Program.Quit()
89
90 tm.WaitFinished(t, teatest.WithFinalTimeout(time.Second*3))
91 uitest.TestGolden(t, drv.Golden())
92 })
93}
94
95type PanicCommand struct{}
96

Callers

nothing calls this directly

Calls 12

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