@@ -93,3 +93,27 @@ func TestLibInstallMultipleSameLibrary(t *testing.T) {
9393 require .NoError (t , err )
9494 requirejson .Len (t , jsonOut , 1 , "A duplicate library install has been detected" )
9595}
96+
97+ func TestDuplicateLibInstallDetection (t * testing.T ) {
98+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
99+ defer env .CleanUp ()
100+ cliEnv := cli .GetDefaultEnv ()
101+ cliEnv ["ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL" ] = "true"
102+
103+ // Make a double install in the sketchbook/user directory
104+ _ ,
_ ,
err := cli .
Run (
"lib" ,
"install" ,
"[email protected] " )
105+ require .NoError (t , err )
106+ otaLibPath := cli .SketchbookDir ().Join ("libraries" , "ArduinoOTA" )
107+ err = otaLibPath .CopyDirTo (otaLibPath .Parent ().Join ("CopyOfArduinoOTA" ))
108+ require .NoError (t , err )
109+ jsonOut , _ , err := cli .Run ("lib" , "list" , "--format" , "json" )
110+ require .NoError (t , err )
111+ requirejson .Len (t , jsonOut , 2 , "Duplicate library install is not detected by the CLI" )
112+
113+ _ , _ , err = cli .Run ("lib" , "install" , "ArduinoOTA" )
114+ require .Error (t , err )
115+ _ , _ , err = cli .Run ("lib" , "upgrade" , "ArduinoOTA" )
116+ require .Error (t , err )
117+ _ , _ , err = cli .Run ("lib" , "uninstall" , "ArduinoOTA" )
118+ require .Error (t , err )
119+ }
0 commit comments