add more unit tests to parseDevices

This commit is contained in:
2022-08-02 20:16:09 -07:00
parent ca83d818fe
commit 0dddd8ca09

View File

@@ -15,6 +15,27 @@ func Test_parseDevices(t *testing.T) {
want []Device want []Device
wantErr bool wantErr bool
}{ }{
{
name: "no devices", args: args{stdout: `List of devices attached`},
wantErr: false,
want: []Device{},
},
{
name: "1 auth dev", args: args{stdout: `List of devices attached
19291FDEE0023W device`},
wantErr: false,
want: []Device{
{IsAuthorized: true, SerialNo: "19291FDEE0023W"},
},
},
{
name: "1 unauth dev", args: args{stdout: `List of devices attached
HT75R0202681 unauthorized`},
wantErr: false,
want: []Device{
{IsAuthorized: false, SerialNo: "HT75R0202681"},
},
},
{ {
name: "2 auth 1 unauth", args: args{stdout: `List of devices attached name: "2 auth 1 unauth", args: args{stdout: `List of devices attached
19291FDEE0023W device 19291FDEE0023W device