Skip to content

Commit 8dc5c2c

Browse files
Migrated TestUpgrade from test_upgrade.py to upgrade_test.go
1 parent 1863f2a commit 8dc5c2c

File tree

2 files changed

+62
-29
lines changed

2 files changed

+62
-29
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// This file is part of arduino-cli.
2+
//
3+
// Copyright 2022 ARDUINO SA (http://www.arduino.cc/)
4+
//
5+
// This software is released under the GNU General Public License version 3,
6+
// which covers the main part of arduino-cli.
7+
// The terms of this license can be found at:
8+
// https://www.gnu.org/licenses/gpl-3.0.en.html
9+
//
10+
// You can be released from the requirements of the above licenses by purchasing
11+
// a commercial license. Buying such a license is mandatory if you want to
12+
// modify or otherwise use the software for commercial activities involving the
13+
// Arduino software without disclosing the source code of your own applications.
14+
// To purchase a commercial license, send an email to license@arduino.cc.
15+
16+
package upgrade_test
17+
18+
import (
19+
"strings"
20+
"testing"
21+
22+
"github.com/arduino/arduino-cli/internal/integrationtest"
23+
"github.com/stretchr/testify/require"
24+
)
25+
26+
func TestUpgrade(t *testing.T) {
27+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
28+
defer env.CleanUp()
29+
30+
// Updates index for cores and libraries
31+
_, _, err := cli.Run("core", "update-idex")
32+
require.NoError(t, err)
33+
_, _, err = cli.Run("lib", "update-idex")
34+
require.NoError(t, err)
35+
36+
// Installs an outdated core and library
37+
_, _, err = cli.Run("core", "install", "arduino:avr@1.6.3")
38+
require.NoError(t, err)
39+
_, _, err = cli.Run("lib", "install", "USBHost@1.0.0")
40+
require.NoError(t, err)
41+
42+
// Installs an outdated core and library
43+
_, _, err = cli.Run("core", "install", "arduino:samd")
44+
require.NoError(t, err)
45+
_, _, err = cli.Run("lib", "install", "ArduinoJson")
46+
require.NoError(t, err)
47+
48+
// Verifies outdated core and libraries are shown
49+
stdout, _, err := cli.Run("outdated")
50+
require.NoError(t, err)
51+
lines := strings.Split(string(stdout), "\n")
52+
require.Contains(t, lines[1], "Arduino AVR Boards")
53+
require.Contains(t, lines[4], "USBHost")
54+
55+
_, _, err = cli.Run("upgrade")
56+
require.NoError(t, err)
57+
58+
// Verifies cores and libraries have been updated
59+
stdout, _, err = cli.Run("outdated")
60+
require.NoError(t, err)
61+
require.Equal(t, string(stdout), "\n")
62+
}

test/test_upgrade.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,6 @@
1616
from pathlib import Path
1717

1818

19-
def test_upgrade(run_command):
20-
# Updates index for cores and libraries
21-
run_command(["core", "update-index"])
22-
run_command(["lib", "update-index"])
23-
24-
# Installs an outdated core and library
25-
run_command(["core", "install", "arduino:avr@1.6.3"])
26-
assert run_command(["lib", "install", "USBHost@1.0.0"])
27-
28-
# Installs latest version of a core and a library
29-
run_command(["core", "install", "arduino:samd"])
30-
assert run_command(["lib", "install", "ArduinoJson"])
31-
32-
# Verifies outdated core and libraries are shown
33-
result = run_command(["outdated"])
34-
assert result.ok
35-
lines = result.stdout.splitlines()
36-
assert "Arduino AVR Boards" in lines[1]
37-
assert "USBHost" in lines[4]
38-
39-
result = run_command(["upgrade"])
40-
assert result.ok
41-
42-
# Verifies cores and libraries have been updated
43-
result = run_command(["outdated"])
44-
assert result.ok
45-
assert result.stdout == "\n"
46-
47-
4819
def test_upgrade_using_library_with_invalid_version(run_command, data_dir):
4920
assert run_command(["update"])
5021

0 commit comments

Comments
 (0)