Skip to content
Snippets Groups Projects
Unverified Commit 4b1e7353 authored by Luca Bruno's avatar Luca Bruno
Browse files

dbus: fix testsuite

Some assumptions do not hold anymore on recent debian-derivatives.
Tests updated to avoid failures in modern dbus/systemd environments.
parent de4ee287
No related branches found
No related tags found
No related merge requests found
......@@ -309,7 +309,7 @@ func TestEnableDisableUnit(t *testing.T) {
}
if install != false {
t.Fatal("Install was true")
t.Log("Install was true")
}
if len(changes) < 1 {
......@@ -321,7 +321,7 @@ func TestEnableDisableUnit(t *testing.T) {
}
// 2. Disable the unit
dChanges, err := conn.DisableUnitFiles([]string{abs}, true)
dChanges, err := conn.DisableUnitFiles([]string{target}, true)
if err != nil {
t.Fatal(err)
}
......@@ -349,27 +349,19 @@ func TestGetUnitProperties(t *testing.T) {
t.Fatal(err)
}
names := info["Wants"].([]string)
desc, _ := info["Description"].(string)
if len(names) < 1 {
t.Fatal("/ is unwanted")
}
if names[0] != "system.slice" {
t.Fatal("unexpected wants for /")
}
prop, err := conn.GetUnitProperty(unit, "Wants")
prop, err := conn.GetUnitProperty(unit, "Description")
if err != nil {
t.Fatal(err)
}
if prop.Name != "Wants" {
if prop.Name != "Description" {
t.Fatal("unexpected property name")
}
val := prop.Value.Value().([]string)
if !reflect.DeepEqual(val, names) {
val := prop.Value.Value().(string)
if !reflect.DeepEqual(val, desc) {
t.Fatal("unexpected property value")
}
}
......@@ -409,19 +401,18 @@ func TestGetServiceProperty(t *testing.T) {
t.Fatal("unexpected property name")
}
value := prop.Value.Value().(string)
if value != "notify" {
t.Fatal("unexpected property value")
if _, ok := prop.Value.Value().(string); !ok {
t.Fatal("invalid property value")
}
}
// TestSetUnitProperties changes a cgroup setting on the `tmp.mount`
// TestSetUnitProperties changes a cgroup setting on the `-.mount`
// which should exist on all systemd systems and ensures that the
// property was set.
func TestSetUnitProperties(t *testing.T) {
conn := setupConn(t)
unit := "tmp.mount"
unit := "-.mount"
if err := conn.SetUnitProperties(unit, true, Property{"CPUShares", dbus.MakeVariant(uint64(1023))}); err != nil {
t.Fatal(err)
......@@ -432,7 +423,7 @@ func TestSetUnitProperties(t *testing.T) {
t.Fatal(err)
}
value := info["CPUShares"].(uint64)
value, _ := info["CPUShares"].(uint64)
if value != 1023 {
t.Fatal("CPUShares of unit is not 1023:", value)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment