forked from ofesseler/gluster_exporter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_test.go
44 lines (38 loc) · 1.04 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import "testing"
func TestContainsVolume(t *testing.T) {
expamle := "doge"
testSlice := []string{"wow", "such", expamle}
if !ContainsVolume(testSlice, expamle) {
t.Fatalf("Hasn't found %v in slice %v", expamle, testSlice)
}
}
type testCases struct {
mountOutput string
expected []string
}
func TestParseMountOutput(t *testing.T) {
var tests = []testCases{
{
mountOutput: "/dev/mapper/cryptroot on / type ext4 (rw,relatime,data=ordered) \n" +
"/dev/mapper/cryptroot on /var/lib/docker/devicemapper type ext4 (rw,relatime,data=ordered)",
expected: []string{"/", "/var/lib/docker/devicemapper"},
},
{
mountOutput: "/dev/mapper/cryptroot on / type ext4 (rw,relatime,data=ordered) \n" +
"",
expected: []string{"/"},
},
}
for _, c := range tests {
mounts, err := parseMountOutput(c.mountOutput)
if err != nil {
t.Error(err)
}
for i, mount := range mounts {
if mount.mountPoint != c.expected[i] {
t.Errorf("mountpoint is %v and %v was expected", mount.mountPoint, c.expected[i])
}
}
}
}