-
Notifications
You must be signed in to change notification settings - Fork 19
/
path_test.go
27 lines (22 loc) · 664 Bytes
/
path_test.go
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
package goflags
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestFlagSet_SetConfigFilePath(t *testing.T) {
configFilePath := "/tmp/config.yaml"
flagSet := NewFlagSet()
var stringSlice StringSlice
flagSet.StringSliceVarP(&stringSlice, "header", "H", []string{}, "Header values. Expected usage: -H \"header1\":\"value1\" -H \"header2\":\"value2\"", StringSliceOptions)
os.Args = []string{
os.Args[0],
}
flagSet.SetConfigFilePath(configFilePath)
err := flagSet.Parse()
assert.Nil(t, err)
gotFilePath, err := flagSet.GetConfigFilePath()
assert.Nil(t, err)
assert.Equal(t, configFilePath, gotFilePath)
tearDown(t.Name())
}