-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpluggedport_test.go
More file actions
47 lines (43 loc) · 871 Bytes
/
pluggedport_test.go
File metadata and controls
47 lines (43 loc) · 871 Bytes
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
package map_usb_devices
import (
"fmt"
"testing"
)
var testCases = []struct {
description string
input1 string
input2 string
want interface{}
}{
{
description: "linux ttyUSB",
input1: "/dev",
input2: "ttyUSB",
want: 2,
},
}
var implementations = []struct {
descr string
f func(r, d string) ([]string, error)
}{
{
descr: "PluggedPort",
f: GetPluggedDevices,
},
}
func TestGetPluggedDevices(t *testing.T) {
for _, impl := range implementations {
t.Run(impl.descr, func(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.description, func(t *testing.T) {
got, _ := impl.f(tc.input1, tc.input2)
if len(got) != tc.want {
t.Fatalf("Test result %v \ngot: %d\nwant: %d", got, len(got), tc.want)
} else {
fmt.Printf("Test result %v", got)
}
})
}
})
}
}