Skip to content

Commit 1114f86

Browse files
committed
Added test for double install with -.zip-path flag
1 parent 8a4489f commit 1114f86

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

internal/integrationtest/lib/lib_test.go

+39
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ package lib_test
1717

1818
import (
1919
"encoding/json"
20+
"io"
21+
"net/http"
2022
"strings"
2123
"testing"
2224

2325
"github.com/arduino/arduino-cli/internal/integrationtest"
26+
"github.com/arduino/go-paths-helper"
2427
"github.com/stretchr/testify/require"
2528
"go.bug.st/testifyjson/requirejson"
2629
)
@@ -164,6 +167,42 @@ func TestDuplicateLibInstallFromGitDetection(t *testing.T) {
164167
requirejson.Parse(t, jsonOut).
165168
Query(`[.[].library.name | select(. == "Arduino SigFox for MKRFox1200")]`).
166169
LengthMustEqualTo(1, "Found multiple installations of Arduino SigFox for MKRFox1200'")
170+
171+
// Try to make a double install by upgrade
172+
_, _, err = cli.Run("lib", "upgrade")
173+
require.NoError(t, err)
174+
175+
// Check if double install happened
176+
jsonOut, _, err = cli.Run("lib", "list", "--format", "json")
177+
require.NoError(t, err)
178+
requirejson.Parse(t, jsonOut).
179+
Query(`[.[].library.name | select(. == "Arduino SigFox for MKRFox1200")]`).
180+
LengthMustEqualTo(1, "Found multiple installations of Arduino SigFox for MKRFox1200'")
181+
182+
// Try to make a double install by zip-installing
183+
tmp, err := paths.MkTempDir("", "")
184+
require.NoError(t, err)
185+
defer tmp.RemoveAll()
186+
tmpZip := tmp.Join("SigFox.zip")
187+
defer tmpZip.Remove()
188+
189+
f, err := tmpZip.Create()
190+
require.NoError(t, err)
191+
resp, err := http.Get("https://github.com/arduino-libraries/SigFox/archive/refs/tags/1.0.3.zip")
192+
require.NoError(t, err)
193+
_, err = io.Copy(f, resp.Body)
194+
require.NoError(t, err)
195+
require.NoError(t, f.Close())
196+
197+
_, _, err = cli.RunWithCustomEnv(cliEnv, "lib", "install", "--zip-path", tmpZip.String())
198+
require.NoError(t, err)
199+
200+
// Check if double install happened
201+
jsonOut, _, err = cli.Run("lib", "list", "--format", "json")
202+
require.NoError(t, err)
203+
requirejson.Parse(t, jsonOut).
204+
Query(`[.[].library.name | select(. == "Arduino SigFox for MKRFox1200")]`).
205+
LengthMustEqualTo(1, "Found multiple installations of Arduino SigFox for MKRFox1200'")
167206
}
168207

169208
func TestLibDepsOutput(t *testing.T) {

0 commit comments

Comments
 (0)