Skip to content

Commit 2d3add3

Browse files
Migrate TestCoreListPlatformWithoutPlatformTxt from test_core.py to core_test.go
1 parent e96003b commit 2d3add3

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

internal/integrationtest/core/core_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,3 +750,29 @@ func TestCoreListDeprecatedPlatformWithInstalledJson(t *testing.T) {
750750
requirejson.Len(t, stdout, 1)
751751
requirejson.Query(t, stdout, ".[] | .deprecated", "true")
752752
}
753+
754+
func TestCoreListPlatformWithoutPlatformTxt(t *testing.T) {
755+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
756+
defer env.CleanUp()
757+
758+
_, _, err := cli.Run("update")
759+
require.NoError(t, err)
760+
761+
stdout, _, err := cli.Run("core", "list", "--format", "json")
762+
require.NoError(t, err)
763+
requirejson.Len(t, stdout, 0)
764+
765+
// Simulates creation of a new core in the sketchbook hardware folder
766+
// without a platforms.txt
767+
testBoardsTxt := paths.New("..", "testdata", "boards.local.txt")
768+
boardsTxt := cli.SketchbookDir().Join("hardware", "some-packager", "some-arch", "boards.txt")
769+
require.NoError(t, boardsTxt.Parent().MkdirAll())
770+
require.NoError(t, testBoardsTxt.CopyTo(boardsTxt))
771+
772+
// Verifies no core is installed
773+
stdout, _, err = cli.Run("core", "list", "--format", "json")
774+
require.NoError(t, err)
775+
requirejson.Len(t, stdout, 1)
776+
requirejson.Query(t, stdout, ".[] | .id", "\"some-packager:some-arch\"")
777+
requirejson.Query(t, stdout, ".[] | .name", "\"some-packager-some-arch\"")
778+
}

test/test_core.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -93,33 +93,6 @@ def test_core_search_update_index_delay(run_command, data_dir):
9393
assert "Downloading index" not in res.stdout
9494

9595

96-
def test_core_list_platform_without_platform_txt(run_command, data_dir):
97-
assert run_command(["update"])
98-
99-
# Verifies no core is installed
100-
res = run_command(["core", "list", "--format", "json"])
101-
assert res.ok
102-
cores = json.loads(res.stdout)
103-
assert len(cores) == 0
104-
105-
# Simulates creation of a new core in the sketchbook hardware folder
106-
# without a platforms.txt
107-
test_boards_txt = Path(__file__).parent / "testdata" / "boards.local.txt"
108-
boards_txt = Path(data_dir, "hardware", "some-packager", "some-arch", "boards.txt")
109-
boards_txt.parent.mkdir(parents=True, exist_ok=True)
110-
boards_txt.touch()
111-
boards_txt.write_bytes(test_boards_txt.read_bytes())
112-
113-
# Verifies no core is installed
114-
res = run_command(["core", "list", "--format", "json"])
115-
assert res.ok
116-
cores = json.loads(res.stdout)
117-
assert len(cores) == 1
118-
core = cores[0]
119-
assert core["id"] == "some-packager:some-arch"
120-
assert core["name"] == "some-packager-some-arch"
121-
122-
12396
@pytest.mark.skipif(
12497
platform.system() in ["Darwin", "Windows"],
12598
reason="macOS by default is case insensitive https://github.com/actions/virtual-environments/issues/865 "

0 commit comments

Comments
 (0)