Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bb2ebd7

Browse files
committedNov 9, 2022
Migrate TestCoreListAllManuallyInstalledCore from test_core.py to core_test.go
1 parent 7915701 commit bb2ebd7

File tree

2 files changed

+36
-27
lines changed

2 files changed

+36
-27
lines changed
 

‎internal/integrationtest/core/core_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package core_test
1818
import (
1919
"fmt"
2020
"runtime"
21+
"strconv"
2122
"strings"
2223
"testing"
2324

@@ -417,3 +418,38 @@ func TestCoreSearchManuallyInstalledCoresNotPrinted(t *testing.T) {
417418
requirejson.NotContains(t, stdout, `[{"id": "arduino-beta-development:avr"}]`)
418419
require.Equal(t, oldJson, stdout)
419420
}
421+
422+
func TestCoreListAllManuallyInstalledCore(t *testing.T) {
423+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
424+
defer env.CleanUp()
425+
426+
_, _, err := cli.Run("core", "update-index")
427+
require.NoError(t, err)
428+
429+
// Verifies only cores in board manager are shown
430+
stdout, _, err := cli.Run("core", "list", "--all", "--format", "json")
431+
require.NoError(t, err)
432+
requirejson.Query(t, stdout, "length > 0", "true")
433+
len, _ := strconv.Atoi(requirejson.Parse(t, stdout).Query("length").String())
434+
435+
// Manually installs a core in sketchbooks hardware folder
436+
gitUrl := "https://github.com/arduino/ArduinoCore-avr.git"
437+
repoDir := cli.SketchbookDir().Join("hardware", "arduino-beta-development", "avr")
438+
_, err = git.PlainClone(repoDir.String(), false, &git.CloneOptions{
439+
URL: gitUrl,
440+
ReferenceName: plumbing.NewTagReferenceName("1.8.3"),
441+
})
442+
require.NoError(t, err)
443+
444+
// Verifies manually installed core is shown
445+
stdout, _, err = cli.Run("core", "list", "--all", "--format", "json")
446+
require.NoError(t, err)
447+
requirejson.Len(t, stdout, len+1)
448+
requirejson.Contains(t, stdout, `[
449+
{
450+
"id": "arduino-beta-development:avr",
451+
"latest": "1.8.3",
452+
"name": "Arduino AVR Boards"
453+
}
454+
]`)
455+
}

‎test/test_core.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,33 +68,6 @@ def ordered(obj):
6868
assert ordered(installed_json) == ordered(expected_installed_json)
6969

7070

71-
def test_core_list_all_manually_installed_core(run_command, data_dir):
72-
assert run_command(["core", "update-index"])
73-
74-
# Verifies only cores in board manager are shown
75-
res = run_command(["core", "list", "--all", "--format", "json"])
76-
assert res.ok
77-
cores = json.loads(res.stdout)
78-
num_cores = len(cores)
79-
assert num_cores > 0
80-
81-
# Manually installs a core in sketchbooks hardware folder
82-
git_url = "https://github.com/arduino/ArduinoCore-avr.git"
83-
repo_dir = Path(data_dir, "hardware", "arduino-beta-development", "avr")
84-
assert Repo.clone_from(git_url, repo_dir, multi_options=["-b 1.8.3"])
85-
86-
# Verifies manually installed core is shown
87-
res = run_command(["core", "list", "--all", "--format", "json"])
88-
assert res.ok
89-
cores = json.loads(res.stdout)
90-
assert num_cores + 1 == len(cores)
91-
mapped = {core["id"]: core for core in cores}
92-
expected_core_id = "arduino-beta-development:avr"
93-
assert expected_core_id in mapped
94-
assert "Arduino AVR Boards" == mapped[expected_core_id]["name"]
95-
assert "1.8.3" == mapped[expected_core_id]["latest"]
96-
97-
9871
def test_core_list_updatable_all_flags(run_command, data_dir):
9972
assert run_command(["core", "update-index"])
10073

0 commit comments

Comments
 (0)
Please sign in to comment.