forked from ltpquang/goadb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevice_info_test.go
53 lines (45 loc) · 1.37 KB
/
device_info_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
package adb
import (
"testing"
"github.com/stretchr/testify/assert"
)
func ParseDeviceList(t *testing.T) {
devs, err := parseDeviceList(`192.168.56.101:5555 device
05856558`, parseDeviceShort)
assert.NoError(t, err)
assert.Len(t, devs, 2)
assert.Equal(t, "192.168.56.101:5555", devs[0].Serial)
assert.Equal(t, "05856558", devs[1].Serial)
}
func TestParseDeviceShort(t *testing.T) {
dev, err := parseDeviceShort("192.168.56.101:5555 device\n")
assert.NoError(t, err)
assert.Equal(t, &DeviceInfo{
Serial: "192.168.56.101:5555"}, dev)
}
func TestParseDeviceLong(t *testing.T) {
dev, err := parseDeviceLong("SERIAL device product:PRODUCT model:MODEL device:DEVICE\n")
assert.NoError(t, err)
assert.Equal(t, &DeviceInfo{
Serial: "SERIAL",
Product: "PRODUCT",
Model: "MODEL",
DeviceInfo: "DEVICE"}, dev)
}
func TestParseDeviceLongUnauthorized(t *testing.T) {
dev, err := parseDeviceLong("SERIAL unauthorized usb:1234 transport_id:8")
assert.NoError(t, err)
assert.Equal(t, &DeviceInfo{
Serial: "SERIAL",
Usb: "1234"}, dev)
}
func TestParseDeviceLongUsb(t *testing.T) {
dev, err := parseDeviceLong("SERIAL device usb:1234 product:PRODUCT model:MODEL device:DEVICE \n")
assert.NoError(t, err)
assert.Equal(t, &DeviceInfo{
Serial: "SERIAL",
Product: "PRODUCT",
Model: "MODEL",
DeviceInfo: "DEVICE",
Usb: "1234"}, dev)
}