github.com/anycable/anycable-go@v1.5.1/cli/cli_test.go (about) 1 package cli 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 "github.com/stretchr/testify/require" 8 "github.com/urfave/cli/v2" 9 ) 10 11 func TestCliConfig(t *testing.T) { 12 _, err, _ := NewConfigFromCLI([]string{"-h"}) 13 require.NoError(t, err) 14 } 15 16 func TestCliConfigCustom(t *testing.T) { 17 var custom string 18 19 _, err, _ := NewConfigFromCLI( 20 []string{"", "-custom=foo"}, 21 WithCLICustomOptions(func() ([]cli.Flag, error) { 22 flag := &cli.StringFlag{ 23 Name: "custom", 24 Destination: &custom, 25 Value: "bar", 26 Required: false, 27 } 28 return []cli.Flag{flag}, nil 29 }), 30 ) 31 32 require.NoError(t, err) 33 assert.Equal(t, "foo", custom) 34 }