Skip to content

Commit 66ed9c8

Browse files
committed
Added integration test
1 parent d5c9c98 commit 66ed9c8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

internal/integrationtest/lib/lib_test.go

+21
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,27 @@ func TestDuplicateLibInstallDetection(t *testing.T) {
145145
require.Contains(t, string(stdErr), "The library ArduinoOTA has multiple installations")
146146
}
147147

148+
func TestDuplicateLibInstallFromGitDetection(t *testing.T) {
149+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
150+
defer env.CleanUp()
151+
cliEnv := cli.GetDefaultEnv()
152+
cliEnv["ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL"] = "true"
153+
154+
// Make a double install in the sketchbook/user directory
155+
_, _, err := cli.Run("lib", "install", "Arduino SigFox for MKRFox1200")
156+
require.NoError(t, err)
157+
158+
_, _, err = cli.RunWithCustomEnv(cliEnv, "lib", "install", "--git-url", "https://github.com/arduino-libraries/SigFox#1.0.3")
159+
require.NoError(t, err)
160+
161+
jsonOut, _, err := cli.Run("lib", "list", "--format", "json")
162+
require.NoError(t, err)
163+
// Count how many libraries with the name "Arduino SigFox for MKRFox1200" are installed
164+
requirejson.Parse(t, jsonOut).
165+
Query(`[.[].library.name | select(. == "Arduino SigFox for MKRFox1200")]`).
166+
LengthMustEqualTo(1, "Found multiple installations of Arduino SigFox for MKRFox1200'")
167+
}
168+
148169
func TestLibDepsOutput(t *testing.T) {
149170
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
150171
defer env.CleanUp()

0 commit comments

Comments
 (0)