Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0e1f3f2

Browse files
fix post rebase
1 parent d9f4fc6 commit 0e1f3f2

File tree

2 files changed

+166
-155
lines changed

2 files changed

+166
-155
lines changed

‎internal/integrationtest/board/board_test.go‎

Lines changed: 97 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func TestBoardList(t *testing.T) {
8686
require.NoError(t, err)
8787
// check is a valid json and contains a list of ports
8888
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) ]`).
9090
MustBeEmpty()
9191
}
9292

@@ -103,29 +103,30 @@ func TestBoardListMock(t *testing.T) {
103103
require.NoError(t, err)
104104

105105
// 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": [
109108
{
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+
}
112127
}
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+
}`)
129130
}
130131

131132
func TestBoardListWithFqbnFilter(t *testing.T) {
@@ -144,8 +145,7 @@ func TestBoardListWithFqbnFilter(t *testing.T) {
144145
// but it would succeed even if the filtering wasn't working properly
145146
// TODO: find a way to simulate connected boards or create a unit test which
146147
// mocks or initializes multiple components
147-
requirejson.Parse(t, stdout).
148-
MustBeEmpty()
148+
requirejson.Query(t, stdout, `.boards | length`, `0`)
149149
}
150150

151151
func TestBoardListWithFqbnFilterInvalid(t *testing.T) {
@@ -434,26 +434,28 @@ func TestBoardSearch(t *testing.T) {
434434
// Verifies boards are returned
435435
requirejson.NotEmpty(t, stdout)
436436
// 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+
]}`)
445446

446447
// Search in non installed boards
447448
stdout, _, err = cli.Run("board", "search", "--format", "json", "nano", "33")
448449
require.NoError(t, err)
449450
// Verifies boards are returned
450451
requirejson.NotEmpty(t, stdout)
451452
// 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+
]}`)
457459

458460
// Install a platform from index
459461
_, _, err = cli.Run("core", "install", "arduino:avr@1.8.3")
@@ -463,27 +465,29 @@ func TestBoardSearch(t *testing.T) {
463465
require.NoError(t, err)
464466
requirejson.NotEmpty(t, stdout)
465467
// 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+
]}`)
477480

478481
stdout, _, err = cli.Run("board", "search", "--format", "json", "arduino", "yun")
479482
require.NoError(t, err)
480483
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+
]}`)
487491

488492
// Manually installs a core in sketchbooks hardware folder
489493
gitUrl := "https://github.com/arduino/ArduinoCore-samd.git"
@@ -498,47 +502,50 @@ func TestBoardSearch(t *testing.T) {
498502
require.NoError(t, err)
499503
requirejson.NotEmpty(t, stdout)
500504
// 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+
]}`)
531537

532538
stdout, _, err = cli.Run("board", "search", "--format", "json", "mkr1000")
533539
require.NoError(t, err)
534540
requirejson.NotEmpty(t, stdout)
535541
// 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+
]}`)
542549
}
543550

544551
func TestBoardAttach(t *testing.T) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /