Skip to content

Commit c21c5f6

Browse files
Migrate TestCoreInstall from test_core.py to core_test.go
1 parent f0bc229 commit c21c5f6

File tree

2 files changed

+46
-38
lines changed

2 files changed

+46
-38
lines changed

internal/integrationtest/core/core_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,49 @@ func TestCoreDownload(t *testing.T) {
256256
require.NoError(t, err)
257257
require.FileExists(t, cli.DownloadDir().Join("packages", "core-ArduinoCore-samd-1.8.12.tar.bz2").String())
258258
}
259+
260+
func TestCoreInstall(t *testing.T) {
261+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
262+
defer env.CleanUp()
263+
264+
_, _, err := cli.Run("core", "update-index")
265+
require.NoError(t, err)
266+
267+
// Install a specific core version
268+
_, _, err = cli.Run("core", "install", "arduino:avr@1.6.16")
269+
require.NoError(t, err)
270+
stdout, _, err := cli.Run("core", "list", "--format", "json")
271+
require.NoError(t, err)
272+
requirejson.Query(t, stdout, ".[] | select(.id == \"arduino:avr\") | .installed==\"1.6.16\"", "true")
273+
274+
// Replace it with the same with --no-overwrite (should NOT fail)
275+
_, _, err = cli.Run("core", "install", "arduino:avr@1.6.16", "--no-overwrite")
276+
require.NoError(t, err)
277+
278+
// Replace it with a more recent one with --no-overwrite (should fail)
279+
_, _, err = cli.Run("core", "install", "arduino:avr@1.6.17", "--no-overwrite")
280+
require.Error(t, err)
281+
282+
// Replace it with a more recent one without --no-overwrite (should succeed)
283+
_, _, err = cli.Run("core", "install", "arduino:avr@1.6.17")
284+
require.NoError(t, err)
285+
stdout, _, err = cli.Run("core", "list", "--format", "json")
286+
require.NoError(t, err)
287+
requirejson.Query(t, stdout, ".[] | select(.id == \"arduino:avr\") | .installed==\"1.6.17\"", "true")
288+
289+
// Confirm core is listed as "updatable"
290+
stdout, _, err = cli.Run("core", "list", "--updatable", "--format", "json")
291+
require.NoError(t, err)
292+
requirejson.Query(t, stdout, ".[] | select(.id == \"arduino:avr\") | .installed==\"1.6.17\"", "true")
293+
294+
// Upgrade the core to latest version
295+
_, _, err = cli.Run("core", "upgrade", "arduino:avr")
296+
require.NoError(t, err)
297+
stdout, _, err = cli.Run("core", "list", "--format", "json")
298+
require.NoError(t, err)
299+
requirejson.Query(t, stdout, ".[] | select(.id == \"arduino:avr\") | .installed==\"1.6.17\"", "false")
300+
// double check the code isn't updatable anymore
301+
stdout, _, err = cli.Run("core", "list", "--updatable", "--format", "json")
302+
require.NoError(t, err)
303+
requirejson.Empty(t, stdout)
304+
}

test/test_core.py

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -58,44 +58,6 @@ def _in(jsondata, name, version=None):
5858
return False
5959

6060

61-
def test_core_install(run_command):
62-
assert run_command(["core", "update-index"])
63-
64-
# Install a specific core version
65-
assert run_command(["core", "install", "arduino:avr@1.6.16"])
66-
result = run_command(["core", "list", "--format", "json"])
67-
assert result.ok
68-
assert _in(result.stdout, "arduino:avr", "1.6.16")
69-
70-
# Replace it with the same with --no-overwrite (should NOT fail)
71-
assert run_command(["core", "install", "arduino:avr@1.6.16", "--no-overwrite"])
72-
73-
# Replace it with a more recent one with --no-overwrite (should fail)
74-
result = run_command(["core", "install", "arduino:avr@1.6.17", "--no-overwrite"])
75-
assert result.failed
76-
77-
# Replace it with a more recent one without --no-overwrite (should succeed)
78-
assert run_command(["core", "install", "arduino:avr@1.6.17"])
79-
result = run_command(["core", "list", "--format", "json"])
80-
assert result.ok
81-
assert _in(result.stdout, "arduino:avr", "1.6.17")
82-
83-
# Confirm core is listed as "updatable"
84-
result = run_command(["core", "list", "--updatable", "--format", "json"])
85-
assert result.ok
86-
assert _in(result.stdout, "arduino:avr", "1.6.17")
87-
88-
# Upgrade the core to latest version
89-
assert run_command(["core", "upgrade", "arduino:avr"])
90-
result = run_command(["core", "list", "--format", "json"])
91-
assert result.ok
92-
assert not _in(result.stdout, "arduino:avr", "1.6.17")
93-
# double check the code isn't updatable anymore
94-
result = run_command(["core", "list", "--updatable", "--format", "json"])
95-
assert result.ok
96-
assert not _in(result.stdout, "arduino:avr")
97-
98-
9961
def test_core_uninstall(run_command):
10062
assert run_command(["core", "update-index"])
10163
assert run_command(["core", "install", "arduino:avr"])

0 commit comments

Comments
 (0)