Skip to content

Commit 4b571e9

Browse files
Migrated TestOutdated from test_outdated.py to outdated_test.go
1 parent aa41d72 commit 4b571e9

File tree

2 files changed

+57
-22
lines changed

2 files changed

+57
-22
lines changed

Diff for: internal/integrationtest/outdated/outdated_test.go

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 [email protected].
15+
16+
package outdated_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 TestOutdated(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-index")
32+
require.NoError(t, err)
33+
_, _, err = cli.Run("lib", "update-index")
34+
require.NoError(t, err)
35+
36+
// Installs an outdated core and library
37+
_, _, err = cli.Run("core", "install", "arduino:[email protected]")
38+
require.NoError(t, err)
39+
_, _, err = cli.Run("lib", "install", "[email protected]")
40+
require.NoError(t, err)
41+
42+
// Installs latest version of a core and a 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 only outdated cores and libraries are returned
49+
stdout, _, err := cli.Run("outdated")
50+
require.NoError(t, err)
51+
lines := strings.Split(string(stdout), "\n")
52+
for i := range lines {
53+
lines[i] = strings.TrimSpace(lines[i])
54+
}
55+
require.Contains(t, lines[1], "Arduino AVR Boards")
56+
require.Contains(t, lines[4], "USBHost")
57+
}

Diff for: test/test_outdated.py

-22
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,6 @@
1515

1616
from pathlib import Path
1717

18-
19-
def test_outdated(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:[email protected]"])
26-
assert run_command(["lib", "install", "[email protected]"])
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 only outdated cores and libraries are returned
33-
result = run_command(["outdated"])
34-
assert result.ok
35-
lines = [l.strip() for l in result.stdout.splitlines()]
36-
assert "Arduino AVR Boards" in lines[1]
37-
assert "USBHost" in lines[4]
38-
39-
4018
def test_outdated_using_library_with_invalid_version(run_command, data_dir):
4119
assert run_command(["update"])
4220

0 commit comments

Comments
 (0)