Пример #1
0
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)
}
Пример #2
0
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
}
Пример #3
0
func TestGetConfigHome(t *testing.T) {
	d := userdir.GetConfigHome()
	require.True(t, strings.HasSuffix(d, "AppData/Roaming"))
}
Пример #4
0
func TestGetConfigHome(t *testing.T) {
	d := userdir.GetConfigHome()
	require.True(t, strings.HasSuffix(d, "Library/Preferences"))
}