Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/config/pathmanager_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type darwinPathManager struct {

func newPlatformPathManager() PathManager {
pm := &darwinPathManager{}
pm.basePathManager.pm = pm
pm.pm = pm

return pm
}
Expand All @@ -25,7 +25,7 @@ func (d *darwinPathManager) ConfigDir() (string, error) {
return "", fmt.Errorf("config dir: %w", err)
}

return ensureDir(filepath.Join(home, "."+RepoName))
return ensureDir(filepath.Join(home, ".config", RepoName))
}

func (d *darwinPathManager) DataDir() (string, error) {
Expand Down
57 changes: 57 additions & 0 deletions pkg/config/pathmanager_darwin_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//go:build darwin

package config

import (
"path/filepath"
"testing"
)

func newTestDarwinPM() PathManager {
pm := &darwinPathManager{}
pm.pm = pm

return pm
}

func TestDarwinConfigDir_IsUnderXDGConfig(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)

pm := newTestDarwinPM()

got, err := pm.ConfigDir()
if err != nil {
t.Fatalf("ConfigDir: %v", err)
}

want := filepath.Join(home, ".config", RepoName)
if got != want {
t.Errorf("ConfigDir = %q, want %q", got, want)
}

dataDir, err := pm.DataDir()
if err != nil {
t.Fatalf("DataDir: %v", err)
}
if got == dataDir {
t.Errorf("ConfigDir and DataDir must be distinct, both = %q", got)
}
}

func TestDarwinConfigFilePath(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv(EnvConfig, "")

pm := newTestDarwinPM()
got, err := pm.ConfigFilePath()
if err != nil {
t.Fatalf("ConfigFilePath: %v", err)
}

want := filepath.Join(home, ".config", RepoName, ConfigFile)
if got != want {
t.Errorf("got %q, want %q", got, want)
}
}
2 changes: 1 addition & 1 deletion pkg/config/pathmanager_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (l *linuxPathManager) ConfigDir() (string, error) {
return "", fmt.Errorf("config dir: %w", err)
}

return ensureDir(filepath.Join(home, "."+RepoName))
return ensureDir(filepath.Join(home, ".config", RepoName))
}

func (l *linuxPathManager) DataDir() (string, error) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/pathmanager_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestLinuxDefaults(t *testing.T) {
fn func() (string, error)
want string
}{
{"ConfigDir", pm.ConfigDir, filepath.Join(home, "."+RepoName)},
{"ConfigDir", pm.ConfigDir, filepath.Join(home, ".config", RepoName)},
{"DataDir", pm.DataDir, filepath.Join(home, "."+RepoName)},
{"CacheDir", pm.CacheDir, filepath.Join(home, ".cache", RepoName)},
{"StateDir", pm.StateDir, filepath.Join(home, "."+RepoName, "state")},
Expand Down Expand Up @@ -79,7 +79,7 @@ func TestConfigFilePathDefault(t *testing.T) {
t.Fatalf("unexpected error: %v", err)
}

want := filepath.Join(home, "."+RepoName, ConfigFile)
want := filepath.Join(home, ".config", RepoName, ConfigFile)
if got != want {
t.Errorf("got %q, want %q", got, want)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/pathmanager_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type windowsPathManager struct {

func newPlatformPathManager() PathManager {
pm := &windowsPathManager{}
pm.basePathManager.pm = pm
pm.pm = pm

return pm
}
Expand Down
Loading