@@ -71,23 +71,6 @@ func TestCorrectBoardListOrdering(t *testing.T) {
71
71
]` )
72
72
}
73
73
74
- func TestBoardList (t * testing.T ) {
75
- env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
76
- defer env .CleanUp ()
77
-
78
- _ , _ , err := cli .Run ("core" , "update-index" )
79
- require .NoError (t , err )
80
-
81
- cli .InstallMockedSerialDiscovery (t )
82
-
83
- stdout , _ , err := cli .Run ("board" , "list" , "--json" )
84
- require .NoError (t , err )
85
- // check is a valid json and contains a list of ports
86
- requirejson .Parse (t , stdout ).
87
- Query (`[ .detected_ports | .[].port | select(.protocol == null or .protocol_label == null) ]` ).
88
- MustBeEmpty ()
89
- }
90
-
91
74
func TestBoardListMock (t * testing.T ) {
92
75
env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
93
76
defer env .CleanUp ()
@@ -97,11 +80,20 @@ func TestBoardListMock(t *testing.T) {
97
80
98
81
cli .InstallMockedSerialDiscovery (t )
99
82
100
- stdout , _ , err := cli .Run ("board" , "list" , "--json" )
101
- require .NoError (t , err )
83
+ t .Run ("IsValidJsonPortList" , func (t * testing.T ) {
84
+ // 1. Check is a valid JSON
85
+ // 2. Check is a valid port list (has address/protocol)
86
+ stdout , _ , err := cli .Run ("board" , "list" , "--json" )
87
+ require .NoError (t , err )
88
+ requirejson .Parse (t , stdout ).
89
+ Query (`[ .detected_ports | .[].port | select(.address == null or .protocol == null) ]` ).
90
+ MustBeEmpty ()
91
+ })
102
92
103
- // check is a valid json and contains a list of ports
104
- requirejson .Contains (t , stdout , `{
93
+ t .Run ("ContainsMockedPorts" , func (t * testing.T ) {
94
+ stdout , _ , err := cli .Run ("board" , "list" , "--json" )
95
+ require .NoError (t , err )
96
+ requirejson .Contains (t , stdout , `{
105
97
"detected_ports": [
106
98
{
107
99
"matching_boards": [
@@ -124,35 +116,20 @@ func TestBoardListMock(t *testing.T) {
124
116
}
125
117
}
126
118
]
127
- }` )
128
- }
129
-
130
- func TestBoardListWithFqbnFilter (t * testing.T ) {
131
- env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
132
- defer env .CleanUp ()
133
-
134
- _ , _ , err := cli .Run ("core" , "update-index" )
135
- require .NoError (t , err )
136
-
137
- cli .InstallMockedSerialDiscovery (t )
138
-
139
- stdout , _ , err := cli .Run ("board" , "list" , "-b" , "foo:bar:baz" , "--json" )
140
- require .NoError (t , err )
141
- requirejson .Query (t , stdout , `.detected_ports | length` , `0` )
142
- }
143
-
144
- func TestBoardListWithFqbnFilterInvalid (t * testing.T ) {
145
- env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
146
- defer env .CleanUp ()
147
-
148
- _ , _ , err := cli .Run ("core" , "update-index" )
149
- require .NoError (t , err )
119
+ }` )
120
+ })
150
121
151
- cli .InstallMockedSerialDiscovery (t )
122
+ t .Run ("ListWithFqbnFilter" , func (t * testing.T ) {
123
+ stdout , _ , err := cli .Run ("board" , "list" , "-b" , "foo:bar:baz" , "--json" )
124
+ require .NoError (t , err )
125
+ requirejson .Query (t , stdout , `.detected_ports | length` , `0` )
126
+ })
152
127
153
- _ , stderr , err := cli .Run ("board" , "list" , "-b" , "yadayada" , "--json" )
154
- require .Error (t , err )
155
- requirejson .Query (t , stderr , ".error" , `"Invalid FQBN: not an FQBN: yadayada"` )
128
+ t .Run ("ListWithFqbnFilterInvalid" , func (t * testing.T ) {
129
+ _ , stderr , err := cli .Run ("board" , "list" , "-b" , "yadayada" , "--json" )
130
+ require .Error (t , err )
131
+ requirejson .Query (t , stderr , ".error" , `"Invalid FQBN: not an FQBN: yadayada"` )
132
+ })
156
133
}
157
134
158
135
func TestBoardListall (t * testing.T ) {
0 commit comments