Skip to content

Commit 2a3157c

Browse files
Migrated TestBoardListallWithManuallyInstalledPlatform from test_board.py to board_test.go
1 parent ebbf26d commit 2a3157c

File tree

2 files changed

+49
-30
lines changed

2 files changed

+49
-30
lines changed

internal/integrationtest/board/board_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
"github.com/arduino/arduino-cli/internal/integrationtest"
2323
"github.com/stretchr/testify/require"
2424
"go.bug.st/testifyjson/requirejson"
25+
"gopkg.in/src-d/go-git.v4"
26+
"gopkg.in/src-d/go-git.v4/plumbing"
2527
)
2628

2729
func TestBoardList(t *testing.T) {
@@ -107,3 +109,50 @@ func TestBoardListall(t *testing.T) {
107109
Query(`[ .boards | .[] | .platform | select(.latest == "") ]`).
108110
MustBeEmpty()
109111
}
112+
113+
func TestBoardListallWithManuallyInstalledPlatform(t *testing.T) {
114+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
115+
defer env.CleanUp()
116+
117+
_, _, err := cli.Run("update")
118+
require.NoError(t, err)
119+
120+
// Manually installs a core in sketchbooks hardware folder
121+
gitUrl := "https://github.com/arduino/ArduinoCore-samd.git"
122+
repoDir := cli.SketchbookDir().Join("hardware", "arduino-beta-development", "samd")
123+
_, err = git.PlainClone(repoDir.String(), false, &git.CloneOptions{
124+
URL: gitUrl,
125+
ReferenceName: plumbing.NewTagReferenceName("1.8.11"),
126+
})
127+
require.NoError(t, err)
128+
129+
stdout, _, err := cli.Run("board", "listall", "--format", "json")
130+
require.NoError(t, err)
131+
132+
requirejson.Query(t, stdout, ".boards | length", "17")
133+
134+
requirejson.Contains(t, stdout, `{
135+
"boards": [
136+
{
137+
"name": "Arduino MKR1000",
138+
"fqbn": "arduino-beta-development:samd:mkr1000",
139+
"platform": {
140+
"id": "arduino-beta-development:samd",
141+
"installed": "1.8.11",
142+
"latest": "1.8.11",
143+
"name": "Arduino SAMD (32-bits ARM Cortex-M0+) Boards",
144+
}
145+
},
146+
{
147+
"name": "Arduino NANO 33 IoT",
148+
"fqbn": "arduino-beta-development:samd:nano_33_iot",
149+
"platform": {
150+
"id": "arduino-beta-development:samd",
151+
"installed": "1.8.11",
152+
"latest": "1.8.11",
153+
"name": "Arduino SAMD (32-bits ARM Cortex-M0+) Boards"
154+
}
155+
}
156+
]
157+
}`)
158+
}

test/test_board.py

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

396396

397-
def test_board_listall_with_manually_installed_platform(run_command, data_dir):
398-
assert run_command(["update"])
399-
400-
# Manually installs a core in sketchbooks hardware folder
401-
git_url = "https://github.com/arduino/ArduinoCore-samd.git"
402-
repo_dir = Path(data_dir, "hardware", "arduino-beta-development", "samd")
403-
assert Repo.clone_from(git_url, repo_dir, multi_options=["-b 1.8.11"])
404-
405-
res = run_command(["board", "listall", "--format", "json"])
406-
assert res.ok
407-
data = json.loads(res.stdout)
408-
boards = {b["fqbn"]: b for b in data["boards"]}
409-
assert len(boards) == 17
410-
assert "arduino-beta-development:samd:nano_33_iot" in boards
411-
assert "Arduino NANO 33 IoT" == boards["arduino-beta-development:samd:nano_33_iot"]["name"]
412-
platform = boards["arduino-beta-development:samd:nano_33_iot"]["platform"]
413-
assert "arduino-beta-development:samd" == platform["id"]
414-
assert "1.8.11" == platform["installed"]
415-
assert "1.8.11" == platform["latest"]
416-
assert "Arduino SAMD (32-bits ARM Cortex-M0+) Boards" == platform["name"]
417-
418-
assert "arduino-beta-development:samd:mkr1000" in boards
419-
assert "Arduino MKR1000" == boards["arduino-beta-development:samd:mkr1000"]["name"]
420-
platform = boards["arduino-beta-development:samd:mkr1000"]["platform"]
421-
assert "arduino-beta-development:samd" == platform["id"]
422-
assert "1.8.11" == platform["installed"]
423-
assert "1.8.11" == platform["latest"]
424-
assert "Arduino SAMD (32-bits ARM Cortex-M0+) Boards" == platform["name"]
425-
426-
427397
def test_board_details(run_command):
428398
run_command(["core", "update-index"])
429399
# Download samd core pinned to 1.8.6

0 commit comments

Comments
 (0)