Skip to content

Commit 1313182

Browse files
committed
dbus: fix stopUnit test helper
1. Make use of t which was unused before. 2. Ignore stopUnit return value. 3. Check os.Remove return value (which can fail the test early). Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent f82fcb4 commit 1313182

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

dbus/methods_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package dbus
1616

1717
import (
1818
"context"
19+
"errors"
1920
"fmt"
2021
"os"
2122
"os/exec"
@@ -52,12 +53,15 @@ func findFixture(target string, t *testing.T) string {
5253
}
5354

5455
func setupUnit(target string, conn *Conn, t *testing.T) {
56+
t.Helper()
5557
// Blindly stop the unit in case it is running
56-
conn.StopUnit(target, "replace", nil)
58+
_, _ = conn.StopUnit(target, "replace", nil)
5759

5860
// Blindly remove the symlink in case it exists
5961
targetRun := filepath.Join("/run/systemd/system/", target)
60-
os.Remove(targetRun)
62+
if err := os.Remove(targetRun); err != nil && !errors.Is(err, os.ErrNotExist) {
63+
t.Fatal(err)
64+
}
6165
}
6266

6367
func linkUnit(target string, conn *Conn, t *testing.T) {

0 commit comments

Comments
 (0)