Skip to content

Commit 1863f2a

Browse files
[skip-changelog] Migrate tests from test_outdated.py to outdated_test.go (#1841)
* Migrated TestOutdated from test_outdated.py to outdated_test.go * Migrated TestOutdatedUsingLibraryWithInvalidVersion to outdated_test.go and deleted test_outdated.py
1 parent c2af7c5 commit 1863f2a

File tree

2 files changed

+90
-60
lines changed

2 files changed

+90
-60
lines changed

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

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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+
}
58+
59+
func TestOutdatedUsingLibraryWithInvalidVersion(t *testing.T) {
60+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
61+
defer env.CleanUp()
62+
63+
_, _, err := cli.Run("update")
64+
require.NoError(t, err)
65+
66+
// Install latest version of a library library
67+
_, _, err = cli.Run("lib", "install", "WiFi101")
68+
require.NoError(t, err)
69+
70+
// Verifies library is correctly returned
71+
stdout, _, err := cli.Run("outdated")
72+
require.NoError(t, err)
73+
require.NotContains(t, string(stdout), "WiFi101")
74+
75+
// Changes the version of the currently installed library so that it's invalid
76+
libPropPath := cli.SketchbookDir().Join("libraries", "WiFi101", "library.properties")
77+
err = libPropPath.WriteFile([]byte("name=WiFi101\nversion=1.0001"))
78+
require.NoError(t, err)
79+
80+
// Verifies library is correctly returned
81+
stdout, _, err = cli.Run("outdated")
82+
require.NoError(t, err)
83+
lines := strings.Split(string(stdout), "\n")
84+
l := make([][]string, len(lines))
85+
for i := range lines {
86+
lines[i] = strings.TrimSpace(lines[i])
87+
l[i] = strings.Split(lines[i], " ")
88+
}
89+
require.Contains(t, l[1][0], "WiFi101")
90+
}

Diff for: test/test_outdated.py

-60
This file was deleted.

0 commit comments

Comments
 (0)