Skip to content

Commit

Permalink
helpers/helpers_test: add test for when HYPRLAND_INSTANCE_SIGNATURE i…
Browse files Browse the repository at this point in the history
…s unset
  • Loading branch information
thiagokokada committed Sep 1, 2024
1 parent e575a7b commit 818f7ce
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions helpers/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,21 @@ func TestGetSocketWithoutXdg(t *testing.T) {
t.Setenv("HYPRLAND_INSTANCE_SIGNATURE", "bar")
t.Setenv("XDG_RUNTIME_DIR", "")

u, err := user.Current()
assert.NoError(t, err)

socket, err := GetSocket(RequestSocket)
assert.NoError(t, err)
assert.Equal(t, socket, "/run/user/"+getUid(t)+"/hypr/bar/.socket.sock")
assert.Equal(t, socket, "/run/user/"+u.Uid+"/hypr/bar/.socket.sock")

socket, err = GetSocket(EventSocket)
assert.NoError(t, err)
assert.Equal(t, socket, "/run/user/"+getUid(t)+"/hypr/bar/.socket2.sock")
assert.Equal(t, socket, "/run/user/"+u.Uid+"/hypr/bar/.socket2.sock")
}

func getUid(t *testing.T) string {
t.Helper()
u, err := user.Current()
assert.NoError(t, err)
return u.Uid
func TestGetSocketError(t *testing.T) {
t.Setenv("HYPRLAND_INSTANCE_SIGNATURE", "")

_, err := GetSocket(RequestSocket)
assert.Error(t, err)
}

0 comments on commit 818f7ce

Please sign in to comment.