Skip to content

Commit 7915701

Browse files
Migrate TestCoreSearchManuallyInstalledCoresNotPrinted from test_core.py to core_test.go
1 parent e4cef88 commit 7915701

File tree

2 files changed

+31
-25
lines changed

2 files changed

+31
-25
lines changed

internal/integrationtest/core/core_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import (
2525
"github.com/arduino/go-paths-helper"
2626
"github.com/stretchr/testify/require"
2727
"go.bug.st/testifyjson/requirejson"
28+
"gopkg.in/src-d/go-git.v4"
29+
"gopkg.in/src-d/go-git.v4/plumbing"
2830
)
2931

3032
func TestCorrectHandlingOfPlatformVersionProperty(t *testing.T) {
@@ -386,3 +388,32 @@ func TestCoreUpdateWithLocalUrl(t *testing.T) {
386388
require.NoError(t, err)
387389
require.Contains(t, string(stdout), "Downloading index: test_index.json downloaded")
388390
}
391+
392+
func TestCoreSearchManuallyInstalledCoresNotPrinted(t *testing.T) {
393+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
394+
defer env.CleanUp()
395+
396+
_, _, err := cli.Run("core", "update-index")
397+
require.NoError(t, err)
398+
399+
// Verifies only cores in board manager are shown
400+
stdout, _, err := cli.Run("core", "search", "--format", "json")
401+
require.NoError(t, err)
402+
requirejson.Query(t, stdout, "length > 0", "true")
403+
oldJson := stdout
404+
405+
// Manually installs a core in sketchbooks hardware folder
406+
gitUrl := "https://github.com/arduino/ArduinoCore-avr.git"
407+
repoDir := cli.SketchbookDir().Join("hardware", "arduino-beta-development", "avr")
408+
_, err = git.PlainClone(repoDir.String(), false, &git.CloneOptions{
409+
URL: gitUrl,
410+
ReferenceName: plumbing.NewTagReferenceName("1.8.3"),
411+
})
412+
require.NoError(t, err)
413+
414+
// Verifies manually installed core is not shown
415+
stdout, _, err = cli.Run("core", "search", "--format", "json")
416+
require.NoError(t, err)
417+
requirejson.NotContains(t, stdout, `[{"id": "arduino-beta-development:avr"}]`)
418+
require.Equal(t, oldJson, stdout)
419+
}

test/test_core.py

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

7070

71-
def test_core_search_manually_installed_cores_not_printed(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", "search", "--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 not shown
87-
res = run_command(["core", "search", "--format", "json"])
88-
assert res.ok
89-
cores = json.loads(res.stdout)
90-
assert num_cores == len(cores)
91-
mapped = {core["id"]: core for core in cores}
92-
core_id = "arduino-beta-development:avr"
93-
assert core_id not in mapped
94-
95-
9671
def test_core_list_all_manually_installed_core(run_command, data_dir):
9772
assert run_command(["core", "update-index"])
9873

0 commit comments

Comments
 (0)