func TestGetConfigHomeFromVariable(t *testing.T) { tmp := os.Getenv("XDG_CONFIG_HOME") os.Setenv("XDG_CONFIG_HOME", "/tmp/foo") d := userdir.GetConfigHome() require.Equal(t, "/tmp/foo", d) os.Setenv("XDG_CONFIG_HOME", tmp) }
func readConfig() error { dir := filepath.Join(userdir.GetConfigHome(), "rsproj") if err := os.MkdirAll(dir, 0755); err != nil { return fmt.Errorf("unable to mkdir '%s'. err=%v", dir, err) } fp := filepath.Join(dir, "config.json") data, err := ioutil.ReadFile(fp) if err != nil { return err } if err := json.Unmarshal(data, &conf); err != nil { return fmt.Errorf("unable to unmarshal JSON. err=%v", err) } return nil }
func TestGetConfigHome(t *testing.T) { d := userdir.GetConfigHome() require.True(t, strings.HasSuffix(d, "AppData/Roaming")) }
func TestGetConfigHome(t *testing.T) { d := userdir.GetConfigHome() require.True(t, strings.HasSuffix(d, "Library/Preferences")) }