@@ -145,6 +145,27 @@ func TestDuplicateLibInstallDetection(t *testing.T) {
145
145
require .Contains (t , string (stdErr ), "The library ArduinoOTA has multiple installations" )
146
146
}
147
147
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
+
148
169
func TestLibDepsOutput (t * testing.T ) {
149
170
env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
150
171
defer env .CleanUp ()
0 commit comments