Skip to content

[skip-changelog] Migrate tests from test_upgrade.py to upgrade_test.go #1859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Migrated TestUpgrade from test_upgrade.py to upgrade_test.go
  • Loading branch information
MatteoPologruto committed Sep 2, 2022
commit 8dc5c2cc9da00978938a7c335773609c7346f72a
62 changes: 62 additions & 0 deletions internal/integrationtest/upgrade/upgrade_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// This file is part of arduino-cli.
//
// Copyright 2022 ARDUINO SA (http://www.arduino.cc/)
//
// This software is released under the GNU General Public License version 3,
// which covers the main part of arduino-cli.
// The terms of this license can be found at:
// https://www.gnu.org/licenses/gpl-3.0.en.html
//
// You can be released from the requirements of the above licenses by purchasing
// a commercial license. Buying such a license is mandatory if you want to
// modify or otherwise use the software for commercial activities involving the
// Arduino software without disclosing the source code of your own applications.
// To purchase a commercial license, send an email to license@arduino.cc.

package upgrade_test

import (
"strings"
"testing"

"github.com/arduino/arduino-cli/internal/integrationtest"
"github.com/stretchr/testify/require"
)

func TestUpgrade(t *testing.T) {
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
defer env.CleanUp()

// Updates index for cores and libraries
_, _, err := cli.Run("core", "update-idex")
require.NoError(t, err)
_, _, err = cli.Run("lib", "update-idex")
require.NoError(t, err)

// Installs an outdated core and library
_, _, err = cli.Run("core", "install", "arduino:avr@1.6.3")
require.NoError(t, err)
_, _, err = cli.Run("lib", "install", "USBHost@1.0.0")
require.NoError(t, err)

// Installs an outdated core and library
_, _, err = cli.Run("core", "install", "arduino:samd")
require.NoError(t, err)
_, _, err = cli.Run("lib", "install", "ArduinoJson")
require.NoError(t, err)

// Verifies outdated core and libraries are shown
stdout, _, err := cli.Run("outdated")
require.NoError(t, err)
lines := strings.Split(string(stdout), "\n")
require.Contains(t, lines[1], "Arduino AVR Boards")
require.Contains(t, lines[4], "USBHost")

_, _, err = cli.Run("upgrade")
require.NoError(t, err)

// Verifies cores and libraries have been updated
stdout, _, err = cli.Run("outdated")
require.NoError(t, err)
require.Equal(t, string(stdout), "\n")
}
29 changes: 0 additions & 29 deletions test/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,6 @@
from pathlib import Path


def test_upgrade(run_command):
# Updates index for cores and libraries
run_command(["core", "update-index"])
run_command(["lib", "update-index"])

# Installs an outdated core and library
run_command(["core", "install", "arduino:avr@1.6.3"])
assert run_command(["lib", "install", "USBHost@1.0.0"])

# Installs latest version of a core and a library
run_command(["core", "install", "arduino:samd"])
assert run_command(["lib", "install", "ArduinoJson"])

# Verifies outdated core and libraries are shown
result = run_command(["outdated"])
assert result.ok
lines = result.stdout.splitlines()
assert "Arduino AVR Boards" in lines[1]
assert "USBHost" in lines[4]

result = run_command(["upgrade"])
assert result.ok

# Verifies cores and libraries have been updated
result = run_command(["outdated"])
assert result.ok
assert result.stdout == "\n"


def test_upgrade_using_library_with_invalid_version(run_command, data_dir):
assert run_command(["update"])

Expand Down