Merge pull request 'power: a lock problem is no longer said once the lock is held' (#46) from fix/power-clears-a-solved-problem into main

This commit was merged in pull request #46.
This commit is contained in:
2026-10-05 08:03:44 +00:00
2 changed files with 12 additions and 0 deletions
+3
View File
@@ -164,6 +164,9 @@ func (w *Watcher) inhibit(l Login1) {
return
}
w.lock = f
if strings.HasPrefix(w.issue, "no delay lock") || strings.HasPrefix(w.issue, "logind") {
w.issue = "" // solved: a problem that no longer holds is not said
}
}
// stillHeld says whether the lock's descriptor is still logind's reference; replaceable in tests.
+9
View File
@@ -68,6 +68,15 @@ func TestALostLockIsTakenAgain(t *testing.T) {
}
}
func TestAProblemIsNoLongerSaidOnceTheLockIsHeld(t *testing.T) {
w := watcher(t, machine(t, nil), &bus{})
w.problem("no delay lock: Permission denied")
w.inhibit(&fakeLogin{})
if s := w.Snapshot(); !s.Inhibiting || s.Problem != "" {
t.Fatalf("%+v", s)
}
}
func TestStdinIsNeverTakenForALock(t *testing.T) {
if IsInhibitor(0) || IsInhibitor(1) || IsInhibitor(2) {
t.Fatal("a standard descriptor was taken for logind's lock")