diff --git a/internal/integrationtest/board/board_test.go b/internal/integrationtest/board/board_test.go index f4759f5b861..ede94e6d679 100644 --- a/internal/integrationtest/board/board_test.go +++ b/internal/integrationtest/board/board_test.go @@ -16,7 +16,6 @@ package board_test import ( - "os" "runtime" "strings" "testing" @@ -73,15 +72,14 @@ func TestCorrectBoardListOrdering(t *testing.T) { } func TestBoardList(t *testing.T) { - if os.Getenv("CI") != "" { - t.Skip("VMs have no serial ports") - } - env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) defer env.CleanUp() _, _, err := cli.Run("core", "update-index") require.NoError(t, err) + + cli.InstallMockedSerialDiscovery(t) + stdout, _, err := cli.Run("board", "list", "--format", "json") require.NoError(t, err) // check is a valid json and contains a list of ports @@ -130,32 +128,28 @@ func TestBoardListMock(t *testing.T) { } func TestBoardListWithFqbnFilter(t *testing.T) { - if os.Getenv("CI") != "" { - t.Skip("VMs have no serial ports") - } - env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) defer env.CleanUp() _, _, err := cli.Run("core", "update-index") require.NoError(t, err) + + cli.InstallMockedSerialDiscovery(t) + stdout, _, err := cli.Run("board", "list", "-b", "foo:bar:baz", "--format", "json") require.NoError(t, err) - // this is a bit of a passpartout test, it actually filters the "bluetooth boards" locally - // but it would succeed even if the filtering wasn't working properly - // TODO: find a way to simulate connected boards or create a unit test which - // mocks or initializes multiple components - requirejson.Query(t, stdout, `.boards | length`, `0`) + requirejson.Query(t, stdout, `.detected_ports | length`, `0`) } func TestBoardListWithFqbnFilterInvalid(t *testing.T) { - if os.Getenv("CI") != "" { - t.Skip("VMs have no serial ports") - } - env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) defer env.CleanUp() + _, _, err := cli.Run("core", "update-index") + require.NoError(t, err) + + cli.InstallMockedSerialDiscovery(t) + _, stderr, err := cli.Run("board", "list", "-b", "yadayada", "--format", "json") require.Error(t, err) requirejson.Query(t, stderr, ".error", `"Invalid FQBN: not an FQBN: yadayada"`)