Skip to content

Commit 8daa1fa

Browse files
Migrate TestCoreListUpdatableAllFlags from test_core.py to core_test.go
1 parent bb2ebd7 commit 8daa1fa

File tree

2 files changed

+35
-27
lines changed

2 files changed

+35
-27
lines changed

internal/integrationtest/core/core_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,3 +453,38 @@ func TestCoreListAllManuallyInstalledCore(t *testing.T) {
453453
}
454454
]`)
455455
}
456+
457+
func TestCoreListUpdatableAllFlags(t *testing.T) {
458+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
459+
defer env.CleanUp()
460+
461+
_, _, err := cli.Run("core", "update-index")
462+
require.NoError(t, err)
463+
464+
// Verifies only cores in board manager are shown
465+
stdout, _, err := cli.Run("core", "list", "--all", "--updatable", "--format", "json")
466+
require.NoError(t, err)
467+
requirejson.Query(t, stdout, "length > 0", "true")
468+
len, _ := strconv.Atoi(requirejson.Parse(t, stdout).Query("length").String())
469+
470+
// Manually installs a core in sketchbooks hardware folder
471+
gitUrl := "https://github.com/arduino/ArduinoCore-avr.git"
472+
repoDir := cli.SketchbookDir().Join("hardware", "arduino-beta-development", "avr")
473+
_, err = git.PlainClone(repoDir.String(), false, &git.CloneOptions{
474+
URL: gitUrl,
475+
ReferenceName: plumbing.NewTagReferenceName("1.8.3"),
476+
})
477+
require.NoError(t, err)
478+
479+
// Verifies using both --updatable and --all flags --all takes precedence
480+
stdout, _, err = cli.Run("core", "list", "--all", "--updatable", "--format", "json")
481+
require.NoError(t, err)
482+
requirejson.Len(t, stdout, len+1)
483+
requirejson.Contains(t, stdout, `[
484+
{
485+
"id": "arduino-beta-development:avr",
486+
"latest": "1.8.3",
487+
"name": "Arduino AVR Boards"
488+
}
489+
]`)
490+
}

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_updatable_all_flags(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", "--updatable", "--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 using both --updatable and --all flags --all takes precedence
87-
res = run_command(["core", "list", "--all", "--updatable", "--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_upgrade_removes_unused_tools(run_command, data_dir):
9972
assert run_command(["update"])
10073

0 commit comments

Comments
 (0)