Skip to content

Commit

Permalink
Add non-existent runtime directory test case
Browse files Browse the repository at this point in the history
  • Loading branch information
adrg committed Oct 29, 2024
1 parent 40d3792 commit 3c39d55
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions xdg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,20 @@ func TestInvalidPaths(t *testing.T) {
require.Error(t, err)
}
}

func TestNonExistentRuntimeDir(t *testing.T) {
var (
envRuntimeDirVar = "XDG_RUNTIME_DIR"
originalRuntimeDir = xdg.RuntimeDir
nonExistentRuntimeDir = filepath.Join(xdg.Home, "runtime")
)
defer os.Setenv(envRuntimeDirVar, originalRuntimeDir)

require.NoError(t, os.Setenv(envRuntimeDirVar, nonExistentRuntimeDir))
xdg.Reload()
require.Equal(t, nonExistentRuntimeDir, xdg.RuntimeDir)

p, err := xdg.RuntimeFile("app.pid")
require.NoError(t, err)
require.Equal(t, os.TempDir(), filepath.Dir(p))
}

0 comments on commit 3c39d55

Please sign in to comment.