@@ -202,6 +202,7 @@ func TestInvalidPaths(t *testing.T) {
202202
203203func TestNonExistentRuntimeDir (t * testing.T ) {
204204 var (
205+ runtimeFiles = []string {"app.pid" , "appname/app.pid" }
205206 envRuntimeDirVar = "XDG_RUNTIME_DIR"
206207 originalRuntimeDir = xdg .RuntimeDir
207208 nonExistentRuntimeDir = filepath .Join (xdg .Home , "runtime" )
@@ -212,7 +213,18 @@ func TestNonExistentRuntimeDir(t *testing.T) {
212213 xdg .Reload ()
213214 require .Equal (t , nonExistentRuntimeDir , xdg .RuntimeDir )
214215
215- p , err := xdg .RuntimeFile ("app.pid" )
216- require .NoError (t , err )
217- require .Equal (t , filepath .Clean (os .TempDir ()), filepath .Dir (p ))
216+ for _ , runtimeFile := range runtimeFiles {
217+ suggestedPath , err := xdg .RuntimeFile (runtimeFile )
218+ require .NoError (t , err )
219+ require .Equal (t , true , strings .HasPrefix (suggestedPath , os .TempDir ()))
220+
221+ f , err := os .Create (suggestedPath )
222+ require .NoError (t , err )
223+ require .NoError (t , f .Close ())
224+ defer os .Remove (suggestedPath )
225+
226+ foundPath , err := xdg .SearchRuntimeFile (runtimeFile )
227+ require .NoError (t , err )
228+ require .Equal (t , suggestedPath , foundPath )
229+ }
218230}
0 commit comments