Skip to content

Commit 5ec2e3f

Browse files
Use mocked serial discovery in TestBoardListWithFqbnFilter
1 parent 354464f commit 5ec2e3f

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

Diff for: internal/integrationtest/board/board_test.go

+12-18
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package board_test
1717

1818
import (
19-
"os"
2019
"runtime"
2120
"strings"
2221
"testing"
@@ -73,15 +72,14 @@ func TestCorrectBoardListOrdering(t *testing.T) {
7372
}
7473

7574
func TestBoardList(t *testing.T) {
76-
if os.Getenv("CI") != "" {
77-
t.Skip("VMs have no serial ports")
78-
}
79-
8075
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
8176
defer env.CleanUp()
8277

8378
_, _, err := cli.Run("core", "update-index")
8479
require.NoError(t, err)
80+
81+
cli.InstallMockedSerialDiscovery(t)
82+
8583
stdout, _, err := cli.Run("board", "list", "--format", "json")
8684
require.NoError(t, err)
8785
// check is a valid json and contains a list of ports
@@ -130,32 +128,28 @@ func TestBoardListMock(t *testing.T) {
130128
}
131129

132130
func TestBoardListWithFqbnFilter(t *testing.T) {
133-
if os.Getenv("CI") != "" {
134-
t.Skip("VMs have no serial ports")
135-
}
136-
137131
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
138132
defer env.CleanUp()
139133

140134
_, _, err := cli.Run("core", "update-index")
141135
require.NoError(t, err)
136+
137+
cli.InstallMockedSerialDiscovery(t)
138+
142139
stdout, _, err := cli.Run("board", "list", "-b", "foo:bar:baz", "--format", "json")
143140
require.NoError(t, err)
144-
// this is a bit of a passpartout test, it actually filters the "bluetooth boards" locally
145-
// but it would succeed even if the filtering wasn't working properly
146-
// TODO: find a way to simulate connected boards or create a unit test which
147-
// mocks or initializes multiple components
148-
requirejson.Query(t, stdout, `.boards | length`, `0`)
141+
requirejson.Query(t, stdout, `.detected_ports | length`, `0`)
149142
}
150143

151144
func TestBoardListWithFqbnFilterInvalid(t *testing.T) {
152-
if os.Getenv("CI") != "" {
153-
t.Skip("VMs have no serial ports")
154-
}
155-
156145
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
157146
defer env.CleanUp()
158147

148+
_, _, err := cli.Run("core", "update-index")
149+
require.NoError(t, err)
150+
151+
cli.InstallMockedSerialDiscovery(t)
152+
159153
_, stderr, err := cli.Run("board", "list", "-b", "yadayada", "--format", "json")
160154
require.Error(t, err)
161155
requirejson.Query(t, stderr, ".error", `"Invalid FQBN: not an FQBN: yadayada"`)

0 commit comments

Comments
 (0)