Skip to content

Commit

Permalink
Merge pull request #24 from thiagokokada/add-helpers-test
Browse files Browse the repository at this point in the history
helpers/helpers_test: add test for when HYPRLAND_INSTANCE_SIGNATURE is unset
  • Loading branch information
thiagokokada authored Sep 1, 2024
2 parents e575a7b + 818f7ce commit d864123
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 d864123

Please sign in to comment.