diff --git a/ee/desktop/runner/runner_test.go b/ee/desktop/runner/runner_test.go index 6b72d311d..f831634f6 100644 --- a/ee/desktop/runner/runner_test.go +++ b/ee/desktop/runner/runner_test.go @@ -18,6 +18,7 @@ import ( "github.com/kolide/launcher/ee/agent/flags/keys" "github.com/kolide/launcher/ee/agent/types/mocks" "github.com/kolide/launcher/ee/desktop/user/notify" + "github.com/kolide/launcher/ee/presencedetection" "github.com/kolide/launcher/pkg/backoff" "github.com/kolide/launcher/pkg/log/multislogger" "github.com/kolide/launcher/pkg/threadsafebuffer" @@ -493,3 +494,33 @@ func countFilesWithPrefix(folderPath, prefix string) (int, error) { return count, nil } + +func TestDesktopUsersProcessesRunner_DetectPresence(t *testing.T) { + t.Parallel() + + t.Run("no user procs", func(t *testing.T) { + t.Parallel() + + runner := DesktopUsersProcessesRunner{} + d, err := runner.DetectPresence("whatevs", time.Second) + require.Error(t, err) + require.Equal(t, presencedetection.DetectionFailedDurationValue, d) + }) + + t.Run("cant connect to user server", func(t *testing.T) { + t.Parallel() + + u, err := user.Current() + require.NoError(t, err) + + runner := DesktopUsersProcessesRunner{} + runner.uidProcs = make(map[string]processRecord) + runner.uidProcs[u.Uid] = processRecord{ + socketPath: "/tmp/doesntexist", + } + + d, err := runner.DetectPresence("whatevs", time.Second) + require.Error(t, err) + require.Equal(t, presencedetection.DetectionFailedDurationValue, d) + }) +}