@@ -86,7 +86,7 @@ func TestBoardList(t *testing.T) {
86
86
require .NoError (t , err )
87
87
// check is a valid json and contains a list of ports
88
88
requirejson .Parse (t , stdout ).
89
- Query (`[ .[].port | select(.protocol == null or .protocol_label == null) ]` ).
89
+ Query (`[ .detected_ports | . [].port | select(.protocol == null or .protocol_label == null) ]` ).
90
90
MustBeEmpty ()
91
91
}
92
92
@@ -103,29 +103,30 @@ func TestBoardListMock(t *testing.T) {
103
103
require .NoError (t , err )
104
104
105
105
// check is a valid json and contains a list of ports
106
- requirejson .Contains (t , stdout , `[
107
- {
108
- "matching_boards": [
106
+ requirejson .Contains (t , stdout , `{
107
+ "detected_ports": [
109
108
{
110
- "name": "Arduino Yún",
111
- "fqbn": "arduino:avr:yun"
109
+ "matching_boards": [
110
+ {
111
+ "name": "Arduino Yún",
112
+ "fqbn": "arduino:avr:yun"
113
+ }
114
+ ],
115
+ "port": {
116
+ "address": "/dev/ttyCIAO",
117
+ "label": "Mocked Serial port",
118
+ "protocol": "serial",
119
+ "protocol_label": "Serial",
120
+ "properties": {
121
+ "pid": "0x0041",
122
+ "serial": "123456",
123
+ "vid": "0x2341"
124
+ },
125
+ "hardware_id": "123456"
126
+ }
112
127
}
113
- ],
114
- "port": {
115
- "address": "/dev/ttyCIAO",
116
- "label": "Mocked Serial port",
117
- "protocol": "serial",
118
- "protocol_label": "Serial",
119
- "properties": {
120
- "pid": "0x0041",
121
- "serial": "123456",
122
- "vid": "0x2341"
123
- },
124
- "hardware_id": "123456"
125
- }
126
- }
127
- ]
128
- ` )
128
+ ]
129
+ }` )
129
130
}
130
131
131
132
func TestBoardListWithFqbnFilter (t * testing.T ) {
@@ -144,8 +145,7 @@ func TestBoardListWithFqbnFilter(t *testing.T) {
144
145
// but it would succeed even if the filtering wasn't working properly
145
146
// TODO: find a way to simulate connected boards or create a unit test which
146
147
// mocks or initializes multiple components
147
- requirejson .Parse (t , stdout ).
148
- MustBeEmpty ()
148
+ requirejson .Query (t , stdout , `.boards | length` , `0` )
149
149
}
150
150
151
151
func TestBoardListWithFqbnFilterInvalid (t * testing.T ) {
@@ -434,26 +434,28 @@ func TestBoardSearch(t *testing.T) {
434
434
// Verifies boards are returned
435
435
requirejson .NotEmpty (t , stdout )
436
436
// Verifies no board has FQBN set since no platform is installed
437
- requirejson .Query (t , stdout , "[ .[] | select(.fqbn) ] | length" , "0" )
438
- requirejson .Contains (t , stdout , `[
439
- {"name": "Arduino UNO"},
440
- {"name": "Arduino Yún"},
441
- {"name": "Arduino Zero"},
442
- {"name": "Arduino Nano 33 BLE"},
443
- {"name": "Arduino Portenta H7"}
444
- ]` )
437
+ requirejson .Query (t , stdout , "[ .boards[] | select(.fqbn) ] | length" , "0" )
438
+ requirejson .Contains (t , stdout , `{
439
+ "boards": [
440
+ {"name": "Arduino UNO"},
441
+ {"name": "Arduino Yún"},
442
+ {"name": "Arduino Zero"},
443
+ {"name": "Arduino Nano 33 BLE"},
444
+ {"name": "Arduino Portenta H7"}
445
+ ]}` )
445
446
446
447
// Search in non installed boards
447
448
stdout , _ , err = cli .Run ("board" , "search" , "--format" , "json" , "nano" , "33" )
448
449
require .NoError (t , err )
449
450
// Verifies boards are returned
450
451
requirejson .NotEmpty (t , stdout )
451
452
// Verifies no board has FQBN set since no platform is installed
452
- requirejson .Query (t , stdout , "[ .[] | select(.fqbn) ] | length" , "0" )
453
- requirejson .Contains (t , stdout , `[
454
- {"name": "Arduino Nano 33 BLE"},
455
- {"name": "Arduino Nano 33 IoT"}
456
- ]` )
453
+ requirejson .Query (t , stdout , "[ .boards[] | select(.fqbn) ] | length" , "0" )
454
+ requirejson .Contains (t , stdout , `{
455
+ "boards": [
456
+ {"name": "Arduino Nano 33 BLE"},
457
+ {"name": "Arduino Nano 33 IoT"}
458
+ ]}` )
457
459
458
460
// Install a platform from index
459
461
_ ,
_ ,
err = cli .
Run (
"core" ,
"install" ,
"arduino:[email protected] " )
@@ -463,27 +465,29 @@ func TestBoardSearch(t *testing.T) {
463
465
require .NoError (t , err )
464
466
requirejson .NotEmpty (t , stdout )
465
467
// Verifies some FQBNs are now returned after installing a platform
466
- requirejson .Query (t , stdout , "[ .[] | select(.fqbn) ] | length" , "26" )
467
- requirejson .Contains (t , stdout , `[
468
- {
469
- "name": "Arduino Yún",
470
- "fqbn": "arduino:avr:yun"
471
- },
472
- {
473
- "name": "Arduino Uno",
474
- "fqbn": "arduino:avr:uno"
475
- }
476
- ]` )
468
+ requirejson .Query (t , stdout , "[ .boards[] | select(.fqbn) ] | length" , "26" )
469
+ requirejson .Contains (t , stdout , `{
470
+ "boards": [
471
+ {
472
+ "name": "Arduino Yún",
473
+ "fqbn": "arduino:avr:yun"
474
+ },
475
+ {
476
+ "name": "Arduino Uno",
477
+ "fqbn": "arduino:avr:uno"
478
+ }
479
+ ]}` )
477
480
478
481
stdout , _ , err = cli .Run ("board" , "search" , "--format" , "json" , "arduino" , "yun" )
479
482
require .NoError (t , err )
480
483
requirejson .NotEmpty (t , stdout )
481
- requirejson .Contains (t , stdout , `[
482
- {
483
- "name": "Arduino Yún",
484
- "fqbn": "arduino:avr:yun"
485
- }
486
- ]` )
484
+ requirejson .Contains (t , stdout , `{
485
+ "boards": [
486
+ {
487
+ "name": "Arduino Yún",
488
+ "fqbn": "arduino:avr:yun"
489
+ }
490
+ ]}` )
487
491
488
492
// Manually installs a core in sketchbooks hardware folder
489
493
gitUrl := "https://github.com/arduino/ArduinoCore-samd.git"
@@ -498,47 +502,50 @@ func TestBoardSearch(t *testing.T) {
498
502
require .NoError (t , err )
499
503
requirejson .NotEmpty (t , stdout )
500
504
// Verifies some FQBNs are now returned after installing a platform
501
- requirejson .Query (t , stdout , "[ .[] | select(.fqbn) ] | length" , "43" )
502
- requirejson .Contains (t , stdout , `[
503
- {
504
- "name": "Arduino Uno",
505
- "fqbn": "arduino:avr:uno"
506
- },
507
- {
508
- "name": "Arduino Yún",
509
- "fqbn": "arduino:avr:yun"
510
- },
511
- {
512
- "name": "Arduino MKR WiFi 1010",
513
- "fqbn": "arduino-beta-development:samd:mkrwifi1010"
514
- },
515
- {
516
- "name": "Arduino MKR1000",
517
- "fqbn": "arduino-beta-development:samd:mkr1000"
518
- },
519
- {
520
- "name": "Arduino MKRZERO",
521
- "fqbn": "arduino-beta-development:samd:mkrzero"
522
- },
523
- {
524
- "name": "Arduino NANO 33 IoT",
525
- "fqbn": "arduino-beta-development:samd:nano_33_iot"
526
- },
527
- {
528
- "fqbn": "arduino-beta-development:samd:arduino_zero_native"
529
- }
530
- ]` )
505
+ requirejson .Query (t , stdout , "[ .boards[] | select(.fqbn) ] | length" , "43" )
506
+ requirejson .Contains (t , stdout , `{
507
+ "boards":
508
+ [
509
+ {
510
+ "name": "Arduino Uno",
511
+ "fqbn": "arduino:avr:uno"
512
+ },
513
+ {
514
+ "name": "Arduino Yún",
515
+ "fqbn": "arduino:avr:yun"
516
+ },
517
+ {
518
+ "name": "Arduino MKR WiFi 1010",
519
+ "fqbn": "arduino-beta-development:samd:mkrwifi1010"
520
+ },
521
+ {
522
+ "name": "Arduino MKR1000",
523
+ "fqbn": "arduino-beta-development:samd:mkr1000"
524
+ },
525
+ {
526
+ "name": "Arduino MKRZERO",
527
+ "fqbn": "arduino-beta-development:samd:mkrzero"
528
+ },
529
+ {
530
+ "name": "Arduino NANO 33 IoT",
531
+ "fqbn": "arduino-beta-development:samd:nano_33_iot"
532
+ },
533
+ {
534
+ "fqbn": "arduino-beta-development:samd:arduino_zero_native"
535
+ }
536
+ ]}` )
531
537
532
538
stdout , _ , err = cli .Run ("board" , "search" , "--format" , "json" , "mkr1000" )
533
539
require .NoError (t , err )
534
540
requirejson .NotEmpty (t , stdout )
535
541
// Verifies some FQBNs are now returned after installing a platform
536
- requirejson .Contains (t , stdout , `[
537
- {
538
- "name": "Arduino MKR1000",
539
- "fqbn": "arduino-beta-development:samd:mkr1000"
540
- }
541
- ]` )
542
+ requirejson .Contains (t , stdout , `{
543
+ "boards": [
544
+ {
545
+ "name": "Arduino MKR1000",
546
+ "fqbn": "arduino-beta-development:samd:mkr1000"
547
+ }
548
+ ]}` )
542
549
}
543
550
544
551
func TestBoardAttach (t * testing.T ) {
0 commit comments