@@ -20,6 +20,7 @@ import (
2020 "fmt"
2121 "io"
2222 "net/http"
23+ "runtime"
2324 "strings"
2425 "testing"
2526 "time"
@@ -1446,3 +1447,34 @@ func TestInstallWithZipPathMultipleLibraries(t *testing.T) {
14461447 require .DirExists (t , wifiInstallDir .String ())
14471448 require .DirExists (t , bleInstallDir .String ())
14481449}
1450+
1451+ func TestInstallWithGitUrlLocalFileUri (t * testing.T ) {
1452+ if runtime .GOOS == "windows" {
1453+ t .Skip ("Using a file uri as git url doesn't work on Windows, " +
1454+ "this must be removed when this issue is fixed: https://github.com/go-git/go-git/issues/247" )
1455+ }
1456+
1457+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
1458+ defer env .CleanUp ()
1459+
1460+ envVar := cli .GetDefaultEnv ()
1461+ envVar ["ARDUINO_ENABLE_UNSAFE_LIBRARY_INSTALL" ] = "true"
1462+
1463+ libInstallDir := cli .SketchbookDir ().Join ("libraries" , "WiFi101" )
1464+ // Verifies library is not installed
1465+ require .NoDirExists (t , libInstallDir .String ())
1466+
1467+ // Clone repository locally
1468+ gitUrl := "https://github.com/arduino-libraries/WiFi101.git"
1469+ repoDir := cli .SketchbookDir ().Join ("WiFi101" )
1470+ _ , err := git .PlainClone (repoDir .String (), false , & git.CloneOptions {
1471+ URL : gitUrl ,
1472+ })
1473+ require .NoError (t , err )
1474+
1475+ _ , _ , err = cli .RunWithCustomEnv (envVar , "lib" , "install" , "--git-url" , "file:///" + repoDir .String ())
1476+ require .NoError (t , err )
1477+
1478+ // Verifies library is installed
1479+ require .DirExists (t , libInstallDir .String ())
1480+ }
0 commit comments