Skip to content

Commit 19d11d0

Browse files
Migrated TestOutdated from test_outdated.py to outdated_test.go
1 parent 9fe8560 commit 19d11d0

File tree

2 files changed

+64
-22
lines changed

2 files changed

+64
-22
lines changed

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

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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/arduino/go-paths-helper"
24+
"github.com/stretchr/testify/require"
25+
"go.bug.st/testsuite"
26+
)
27+
28+
func TestOutdated(t *testing.T) {
29+
env := testsuite.NewEnvironment(t)
30+
defer env.CleanUp()
31+
32+
cli := integrationtest.NewArduinoCliWithinEnvironment(env, &integrationtest.ArduinoCLIConfig{
33+
ArduinoCLIPath: paths.New("..", "..", "..", "arduino-cli"),
34+
UseSharedStagingFolder: true,
35+
})
36+
37+
//Updates index for cores and libraries
38+
_, _, err := cli.Run("core", "update-index")
39+
require.NoError(t, err)
40+
_, _, err = cli.Run("lib", "update-index")
41+
require.NoError(t, err)
42+
43+
// Installs an outdated core and library
44+
_, _, err = cli.Run("core", "install", "arduino:[email protected]")
45+
require.NoError(t, err)
46+
_, _, err = cli.Run("lib", "install", "[email protected]")
47+
require.NoError(t, err)
48+
49+
// Installs latest version of a core and a library
50+
_, _, err = cli.Run("core", "install", "arduino:samd")
51+
require.NoError(t, err)
52+
_, _, err = cli.Run("lib", "install", "ArduinoJson")
53+
require.NoError(t, err)
54+
55+
// Verifies only outdated cores and libraries are returned
56+
stdout, _, err := cli.Run("outdated")
57+
require.NoError(t, err)
58+
lines := strings.Split(string(stdout), "\n")
59+
for i := range lines {
60+
lines[i] = strings.TrimSpace(lines[i])
61+
}
62+
require.Contains(t, lines[1], "Arduino AVR Boards")
63+
require.Contains(t, lines[4], "USBHost")
64+
}

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)