Skip to content

Commit 48c72f1

Browse files
committed
Add a unit test to check GetUnitProperties rejects invalid units.
1 parent e47227d commit 48c72f1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

dbus/methods_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,18 @@ func TestGetUnitProperties(t *testing.T) {
138138
t.Fatal("unexpected wants for /")
139139
}
140140
}
141+
142+
// TestGetUnitPropertiesRejectsInvalidName attempts to get the properties for a
143+
// unit with an invalid name. This test should be run with --test.timeout set,
144+
// as a fail will manifest as GetUnitProperties hanging indefinitely.
145+
func TestGetUnitPropertiesRejectsInvalidName(t *testing.T) {
146+
conn := setupConn(t)
147+
148+
unit := "//invalid#$^/"
149+
150+
_, err := conn.GetUnitProperties(unit)
151+
152+
if err == nil {
153+
t.Fatal("Expected an error, got nil")
154+
}
155+
}

0 commit comments

Comments
 (0)