aboutsummaryrefslogtreecommitdiff
path: root/collector/systemd_linux_test.go
diff options
context:
space:
mode:
authorTom Wilkie <tom.wilkie@gmail.com>2018-01-31 15:22:17 +0000
committerTom Wilkie <tom.wilkie@gmail.com>2018-01-31 15:22:17 +0000
commit6833eec18747789a73417b2d4d44a4003bb83f13 (patch)
tree48c498a4e22398f80542ed767dc8318cce3b467f /collector/systemd_linux_test.go
parent0316baccebeeacdaa73fb32ed7fff7787aff9fd3 (diff)
downloadprometheus_node_collector-6833eec18747789a73417b2d4d44a4003bb83f13.tar.bz2
prometheus_node_collector-6833eec18747789a73417b2d4d44a4003bb83f13.tar.xz
prometheus_node_collector-6833eec18747789a73417b2d4d44a4003bb83f13.zip
Fix tests.
Diffstat (limited to 'collector/systemd_linux_test.go')
-rw-r--r--collector/systemd_linux_test.go96
1 files changed, 52 insertions, 44 deletions
diff --git a/collector/systemd_linux_test.go b/collector/systemd_linux_test.go
index 0555d46..a68f6cd 100644
--- a/collector/systemd_linux_test.go
+++ b/collector/systemd_linux_test.go
@@ -22,61 +22,69 @@ import (
22) 22)
23 23
24// Creates mock UnitLists 24// Creates mock UnitLists
25func getUnitListFixtures() [][]dbus.UnitStatus { 25func getUnitListFixtures() [][]unit {
26 fixture1 := []dbus.UnitStatus{ 26 fixture1 := []unit{
27 { 27 {
28 Name: "foo", 28 UnitStatus: dbus.UnitStatus{
29 Description: "foo desc", 29 Name: "foo",
30 LoadState: "loaded", 30 Description: "foo desc",
31 ActiveState: "active", 31 LoadState: "loaded",
32 SubState: "running", 32 ActiveState: "active",
33 Followed: "", 33 SubState: "running",
34 Path: "/org/freedesktop/systemd1/unit/foo", 34 Followed: "",
35 JobId: 0, 35 Path: "/org/freedesktop/systemd1/unit/foo",
36 JobType: "", 36 JobId: 0,
37 JobPath: "/", 37 JobType: "",
38 JobPath: "/",
39 },
38 }, 40 },
39 { 41 {
40 Name: "bar", 42 UnitStatus: dbus.UnitStatus{
41 Description: "bar desc", 43 Name: "bar",
42 LoadState: "not-found", 44 Description: "bar desc",
43 ActiveState: "inactive", 45 LoadState: "not-found",
44 SubState: "dead", 46 ActiveState: "inactive",
45 Followed: "", 47 SubState: "dead",
46 Path: "/org/freedesktop/systemd1/unit/bar", 48 Followed: "",
47 JobId: 0, 49 Path: "/org/freedesktop/systemd1/unit/bar",
48 JobType: "", 50 JobId: 0,
49 JobPath: "/", 51 JobType: "",
52 JobPath: "/",
53 },
50 }, 54 },
51 { 55 {
52 Name: "foobar", 56 UnitStatus: dbus.UnitStatus{
53 Description: "bar desc", 57 Name: "foobar",
54 LoadState: "not-found", 58 Description: "bar desc",
55 ActiveState: "inactive", 59 LoadState: "not-found",
56 SubState: "dead", 60 ActiveState: "inactive",
57 Followed: "", 61 SubState: "dead",
58 Path: "/org/freedesktop/systemd1/unit/bar", 62 Followed: "",
59 JobId: 0, 63 Path: "/org/freedesktop/systemd1/unit/bar",
60 JobType: "", 64 JobId: 0,
61 JobPath: "/", 65 JobType: "",
66 JobPath: "/",
67 },
62 }, 68 },
63 { 69 {
64 Name: "baz", 70 UnitStatus: dbus.UnitStatus{
65 Description: "bar desc", 71 Name: "baz",
66 LoadState: "not-found", 72 Description: "bar desc",
67 ActiveState: "inactive", 73 LoadState: "not-found",
68 SubState: "dead", 74 ActiveState: "inactive",
69 Followed: "", 75 SubState: "dead",
70 Path: "/org/freedesktop/systemd1/unit/bar", 76 Followed: "",
71 JobId: 0, 77 Path: "/org/freedesktop/systemd1/unit/bar",
72 JobType: "", 78 JobId: 0,
73 JobPath: "/", 79 JobType: "",
80 JobPath: "/",
81 },
74 }, 82 },
75 } 83 }
76 84
77 fixture2 := []dbus.UnitStatus{} 85 fixture2 := []unit{}
78 86
79 return [][]dbus.UnitStatus{fixture1, fixture2} 87 return [][]unit{fixture1, fixture2}
80} 88}
81 89
82func TestSystemdCollectorDoesntCrash(t *testing.T) { 90func TestSystemdCollectorDoesntCrash(t *testing.T) {