File: global_test.go

package info (click to toggle)
golang-github-alecthomas-kong 0.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 620 kB
  • sloc: makefile: 2
file content (31 lines) | stat: -rw-r--r-- 506 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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")
}