github.com/drycc/workflow-cli@v1.5.3-0.20240322092846-d4ee25983af9/settings/utils_test.go (about) 1 package settings 2 3 import ( 4 "os" 5 "path/filepath" 6 "testing" 7 8 "github.com/stretchr/testify/assert" 9 ) 10 11 type confgCases struct { 12 Input string 13 Expected string 14 } 15 16 func TestSelectSettings(t *testing.T) { 17 t.Parallel() 18 cases := []confgCases{ 19 {"test", filepath.Join(FindHome(), ".drycc", "test.json")}, 20 {"", filepath.Join(FindHome(), ".drycc", "client.json")}, 21 {"~/test.json", "~/test.json"}, 22 {"/opt/test.json", "/opt/test.json"}, 23 } 24 25 for _, check := range cases { 26 assert.Equal(t, locateSettingsFile(check.Input), check.Expected, "case") 27 } 28 29 // Check that env variable is used. 30 location := "/test/test.json" 31 os.Setenv("DRYCC_PROFILE", location) 32 assert.Equal(t, locateSettingsFile(""), location, "case") 33 }