From 0b7eaf1e6d0047cb461497851f2baf5246531a43 Mon Sep 17 00:00:00 2001 From: Matteo Pologruto Date: Fri, 12 Aug 2022 15:07:39 +0200 Subject: [PATCH] Migrated TestCacheClean to cache_test.go and deleted test_cache.py --- internal/integrationtest/cache/cache_test.go | 50 ++++++++++++++++++++ test/test_cache.py | 33 ------------- 2 files changed, 50 insertions(+), 33 deletions(-) create mode 100644 internal/integrationtest/cache/cache_test.go delete mode 100644 test/test_cache.py diff --git a/internal/integrationtest/cache/cache_test.go b/internal/integrationtest/cache/cache_test.go new file mode 100644 index 00000000000..8c45123115a --- /dev/null +++ b/internal/integrationtest/cache/cache_test.go @@ -0,0 +1,50 @@ +// 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 cache_test + +import ( + "testing" + + "github.com/arduino/arduino-cli/internal/integrationtest" + "github.com/arduino/go-paths-helper" + "github.com/stretchr/testify/require" + "go.bug.st/testsuite" +) + +func TestCacheClean(t *testing.T) { + // Clean the cache under arduino caching file directory which is "/staging" + + env := testsuite.NewEnvironment(t) + defer env.CleanUp() + + cli := integrationtest.NewArduinoCliWithinEnvironment(env, &integrationtest.ArduinoCLIConfig{ + ArduinoCLIPath: paths.New("..", "..", "..", "arduino-cli"), + UseSharedStagingFolder: true, + }) + + _, _, err := cli.Run("cache", "clean") + require.NoError(t, err) + + // Generate /staging directory + _, _, err = cli.Run("lib", "list") + require.NoError(t, err) + + _, _, err = cli.Run("cache", "clean") + require.NoError(t, err) + + staging := cli.DataDir().Join("staging") + require.False(t, staging.IsDir()) +} diff --git a/test/test_cache.py b/test/test_cache.py deleted file mode 100644 index f7c3db97b09..00000000000 --- a/test/test_cache.py +++ /dev/null @@ -1,33 +0,0 @@ -# This file is part of arduino-cli. -# -# Copyright 2020 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. -import os - - -def test_cache_clean(run_command, data_dir): - """ - Clean the cache under arduino caching file directory which is - "/staging" - """ - result = run_command(["cache", "clean"]) - assert result.ok - - # Generate /staging directory - result = run_command(["lib", "list"]) - assert result.ok - - result = run_command(["cache", "clean"]) - assert result.ok - - assert not os.path.isdir(os.path.join(data_dir, "staging"))