|
|
@ -22,61 +22,69 @@ import ( |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// Creates mock UnitLists
|
|
|
|
// Creates mock UnitLists
|
|
|
|
func getUnitListFixtures() [][]dbus.UnitStatus { |
|
|
|
func getUnitListFixtures() [][]unit { |
|
|
|
fixture1 := []dbus.UnitStatus{ |
|
|
|
fixture1 := []unit{ |
|
|
|
{ |
|
|
|
{ |
|
|
|
Name: "foo", |
|
|
|
UnitStatus: dbus.UnitStatus{ |
|
|
|
Description: "foo desc", |
|
|
|
Name: "foo", |
|
|
|
LoadState: "loaded", |
|
|
|
Description: "foo desc", |
|
|
|
ActiveState: "active", |
|
|
|
LoadState: "loaded", |
|
|
|
SubState: "running", |
|
|
|
ActiveState: "active", |
|
|
|
Followed: "", |
|
|
|
SubState: "running", |
|
|
|
Path: "/org/freedesktop/systemd1/unit/foo", |
|
|
|
Followed: "", |
|
|
|
JobId: 0, |
|
|
|
Path: "/org/freedesktop/systemd1/unit/foo", |
|
|
|
JobType: "", |
|
|
|
JobId: 0, |
|
|
|
JobPath: "/", |
|
|
|
JobType: "", |
|
|
|
|
|
|
|
JobPath: "/", |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
Name: "bar", |
|
|
|
UnitStatus: dbus.UnitStatus{ |
|
|
|
Description: "bar desc", |
|
|
|
Name: "bar", |
|
|
|
LoadState: "not-found", |
|
|
|
Description: "bar desc", |
|
|
|
ActiveState: "inactive", |
|
|
|
LoadState: "not-found", |
|
|
|
SubState: "dead", |
|
|
|
ActiveState: "inactive", |
|
|
|
Followed: "", |
|
|
|
SubState: "dead", |
|
|
|
Path: "/org/freedesktop/systemd1/unit/bar", |
|
|
|
Followed: "", |
|
|
|
JobId: 0, |
|
|
|
Path: "/org/freedesktop/systemd1/unit/bar", |
|
|
|
JobType: "", |
|
|
|
JobId: 0, |
|
|
|
JobPath: "/", |
|
|
|
JobType: "", |
|
|
|
|
|
|
|
JobPath: "/", |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
Name: "foobar", |
|
|
|
UnitStatus: dbus.UnitStatus{ |
|
|
|
Description: "bar desc", |
|
|
|
Name: "foobar", |
|
|
|
LoadState: "not-found", |
|
|
|
Description: "bar desc", |
|
|
|
ActiveState: "inactive", |
|
|
|
LoadState: "not-found", |
|
|
|
SubState: "dead", |
|
|
|
ActiveState: "inactive", |
|
|
|
Followed: "", |
|
|
|
SubState: "dead", |
|
|
|
Path: "/org/freedesktop/systemd1/unit/bar", |
|
|
|
Followed: "", |
|
|
|
JobId: 0, |
|
|
|
Path: "/org/freedesktop/systemd1/unit/bar", |
|
|
|
JobType: "", |
|
|
|
JobId: 0, |
|
|
|
JobPath: "/", |
|
|
|
JobType: "", |
|
|
|
|
|
|
|
JobPath: "/", |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
Name: "baz", |
|
|
|
UnitStatus: dbus.UnitStatus{ |
|
|
|
Description: "bar desc", |
|
|
|
Name: "baz", |
|
|
|
LoadState: "not-found", |
|
|
|
Description: "bar desc", |
|
|
|
ActiveState: "inactive", |
|
|
|
LoadState: "not-found", |
|
|
|
SubState: "dead", |
|
|
|
ActiveState: "inactive", |
|
|
|
Followed: "", |
|
|
|
SubState: "dead", |
|
|
|
Path: "/org/freedesktop/systemd1/unit/bar", |
|
|
|
Followed: "", |
|
|
|
JobId: 0, |
|
|
|
Path: "/org/freedesktop/systemd1/unit/bar", |
|
|
|
JobType: "", |
|
|
|
JobId: 0, |
|
|
|
JobPath: "/", |
|
|
|
JobType: "", |
|
|
|
|
|
|
|
JobPath: "/", |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fixture2 := []dbus.UnitStatus{} |
|
|
|
fixture2 := []unit{} |
|
|
|
|
|
|
|
|
|
|
|
return [][]dbus.UnitStatus{fixture1, fixture2} |
|
|
|
return [][]unit{fixture1, fixture2} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestSystemdCollectorDoesntCrash(t *testing.T) { |
|
|
|
func TestSystemdCollectorDoesntCrash(t *testing.T) { |
|
|
|