MCPcopy Create free account
hub / github.com/ProspectOne/perfops-cli / TestShowErrorOnly

Function TestShowErrorOnly

cmd/root_test.go:127–147  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

125}
126
127func TestShowErrorOnly(t *testing.T) {
128 expErr := errors.New("error")
129 cmd := &cobra.Command{
130 Use: "test-only",
131 RunE: func(cmd *cobra.Command, args []string) error {
132 return expErr
133 },
134 }
135 var b bytes.Buffer
136 rootCmd.ResetFlags()
137 rootCmd.SetOutput(&b)
138 rootCmd.AddCommand(cmd)
139 initRootCmd()
140 rootCmd.SetArgs([]string{"test-only"})
141 if err := rootCmd.Execute(); err != expErr {
142 t.Fatalf("exepected %v; got %v", expErr, err)
143 }
144 if got, exp := b.String(), "Error: error\n"; got != exp {
145 t.Fatalf("expected %#v; got %q", exp, got)
146 }
147}
148
149type unauthedError struct{}
150

Callers

nothing calls this directly

Calls 2

initRootCmdFunction · 0.85
SetOutputMethod · 0.80

Tested by

no test coverage detected