Codebase list golang-github-alecthomas-kong / 2476d98b-4cc3-4109-9605-49ac95194e07/upstream global_test.go
2476d98b-4cc3-4109-9605-49ac95194e07/upstream

Tree @2476d98b-4cc3-4109-9605-49ac95194e07/upstream (Download .tar.gz)

global_test.go @2476d98b-4cc3-4109-9605-49ac95194e07/upstreamraw · history · blame

package kong

import (
	"os"
	"testing"

	"github.com/stretchr/testify/require"
)

func TestParseHandlingBadBuild(t *testing.T) {
	var cli struct {
		Enabled bool `kong:"fail='"`
	}

	args := os.Args
	defer func() {
		os.Args = args
	}()

	os.Args = []string{os.Args[0], "hi"}

	defer func() {
		if r := recover(); r != nil {
			require.Equal(t, Error{msg: "fail=' is not quoted properly"}, r)
		}
	}()

	Parse(&cli, Exit(func(_ int) { panic("exiting") }))

	require.Fail(t, "we were expecting a panic")
}