test(778): capture stderr and stdout during tests

Steve Moyer created

Change summary

commands/env.go | 3 +++
1 file changed, 3 insertions(+)

Detailed changes

commands/env.go 🔗

@@ -141,6 +141,9 @@ func loadBackendEnsureUser(env *Env) func(*cobra.Command, []string) error {
 // This wrapper style is necessary because a Cobra PostE function does not run if RunE return an error.
 func closeBackend(env *Env, runE func(cmd *cobra.Command, args []string) error) func(*cobra.Command, []string) error {
 	return func(cmd *cobra.Command, args []string) error {
+		env.err = out{Writer: cmd.ErrOrStderr()}
+		env.out = out{Writer: cmd.OutOrStdout()}
+
 		errRun := runE(cmd, args)
 
 		if env.backend == nil {