-
Notifications
You must be signed in to change notification settings - Fork 0
/
udev_test.go
55 lines (53 loc) · 1.1 KB
/
udev_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
45
46
47
48
49
50
51
52
53
54
55
package mxdisk
import (
"reflect"
"regexp"
"testing"
)
func TestUdevadmInfo_parseOutput(t *testing.T) {
type fields struct {
ekv map[string]string
}
type args struct {
rex *regexp.Regexp
str string
}
tests := []struct {
name string
fields fields
args args
want fields
}{
{
name: "udevadm KV parser",
fields: fields{
ekv: map[string]string{},
},
args: args{
rex: udevadmRegexpE(),
str: `N: sdd5
E: DEVLINKS=/dev/disk/by-path/pci-0000:00:1f.2-ata-4-part5 /dev/disk/by-uuid/xxxx-xxxx-xxx
E: ID_BUS=ata
E: ID_FS_TYPE=ext4`,
},
want: fields{
ekv: map[string]string{
"DEVLINKS": "/dev/disk/by-path/pci-0000:00:1f.2-ata-4-part5 /dev/disk/by-uuid/xxxx-xxxx-xxx", // double values
"ID_FS_TYPE": "ext4",
"ID_BUS": "ata",
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p := UdevadmInfo{
ekv: tt.fields.ekv,
}
p.parseOutput(tt.args.rex, tt.args.str)
if !reflect.DeepEqual(tt.fields, tt.want) {
t.Errorf("UdevadmInfo.parseOutput() = %v, want %v", tt.fields, tt.want)
}
})
}
}