Skip to content

Commit a3a2de0

Browse files
Migrated TestBoardList from test_board.py to board_test.go
1 parent 2480d93 commit a3a2de0

File tree

2 files changed

+43
-13
lines changed

2 files changed

+43
-13
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// This file is part of arduino-cli.
2+
//
3+
// Copyright 2022 ARDUINO SA (http://www.arduino.cc/)
4+
//
5+
// This software is released under the GNU General Public License version 3,
6+
// which covers the main part of arduino-cli.
7+
// The terms of this license can be found at:
8+
// https://www.gnu.org/licenses/gpl-3.0.en.html
9+
//
10+
// You can be released from the requirements of the above licenses by purchasing
11+
// a commercial license. Buying such a license is mandatory if you want to
12+
// modify or otherwise use the software for commercial activities involving the
13+
// Arduino software without disclosing the source code of your own applications.
14+
// To purchase a commercial license, send an email to [email protected].
15+
16+
package board_test
17+
18+
import (
19+
"os"
20+
"testing"
21+
22+
"github.com/arduino/arduino-cli/internal/integrationtest"
23+
"github.com/stretchr/testify/require"
24+
"go.bug.st/testifyjson/requirejson"
25+
)
26+
27+
func TestBoardList(t *testing.T) {
28+
if os.Getenv("CI") != "" {
29+
t.Skip("VMs have no serial ports")
30+
}
31+
32+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
33+
defer env.CleanUp()
34+
35+
_, _, err := cli.Run("core", "update-index")
36+
require.NoError(t, err)
37+
stdout, _, err := cli.Run("board", "list", "--format", "json")
38+
require.NoError(t, err)
39+
// check is a valid json and contains a list of ports
40+
requirejson.Parse(t, stdout).
41+
Query(`[ .[].port | select(.protocol == null or .protocol_label == null) ]`).
42+
MustBeEmpty()
43+
}

test/test_board.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -394,19 +394,6 @@
394394
""" # noqa: E501
395395

396396

397-
@pytest.mark.skipif(running_on_ci(), reason="VMs have no serial ports")
398-
def test_board_list(run_command):
399-
run_command(["core", "update-index"])
400-
result = run_command(["board", "list", "--format", "json"])
401-
assert result.ok
402-
# check is a valid json and contains a list of ports
403-
ports = json.loads(result.stdout)
404-
assert isinstance(ports, list)
405-
for port in ports:
406-
assert "protocol" in port["port"]
407-
assert "protocol_label" in port["port"]
408-
409-
410397
def test_board_list_with_invalid_discovery(run_command, data_dir):
411398
run_command(["core", "update-index"])
412399
result = run_command(["board", "list"])

0 commit comments

Comments
 (0)