@ -18,13 +18,13 @@ package main
import (
"bytes"
"errors"
"os"
"os/exec"
"runtime"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestCliPluginExitCode ( t * testing . T ) {
@ -62,20 +62,13 @@ func TestCliPluginExitCode(t *testing.T) {
err := cmd . Run ( )
exiterr := & exec . ExitError { }
ok := errors . As ( err , & exiterr )
if ! ok {
t . Fatalf ( "Unexpected error type returned by os.Exit: %T" , err )
}
require . ErrorAs ( t , err , & exiterr )
assert . Empty ( t , stdout . String ( ) )
expectedStderr := "level=WARN msg=\"failed to load plugin (ignoring)\" plugin_yaml=../../pkg/cmd/testdata/helmhome/helm/plugins/noversion/plugin.yaml error=\"failed to load plugin \\\"../../pkg/cmd/testdata/helmhome/helm/plugins/noversion\\\": plugin `version` is required\"\nError: plugin \"exitwith\" exited with error\n"
if stderr . String ( ) != expectedStderr {
t . Errorf ( "Expected %q written to stderr: Got %q" , expectedStderr , stderr . String ( ) )
}
assert . Equal ( t , expectedStderr , stderr . String ( ) )
if exiterr . ExitCode ( ) != 43 {
t . Errorf ( "Expected exit code 43: Got %d" , exiterr . ExitCode ( ) )
}
assert . Equal ( t , 43 , exiterr . ExitCode ( ) )
}
}