@@ -20,6 +20,7 @@ import (
2020 "fmt"
2121 "io"
2222 "net/http"
23+ "runtime"
2324 "strings"
2425 "testing"
2526 "time"
@@ -1475,3 +1476,34 @@ func TestInstallWithZipPathMultipleLibraries(t *testing.T) {
14751476 require .DirExists (t , wifiInstallDir .String ())
14761477 require .DirExists (t , bleInstallDir .String ())
14771478}
1479+
1480+ func TestInstallWithGitUrlLocalFileUri (t * testing.T ) {
1481+ if runtime .GOOS == "windows" {
1482+ t .Skip ("Using a file uri as git url doesn't work on Windows, " +
1483+ "this must be removed when this issue is fixed: https://github.com/go-git/go-git/issues/247" )
1484+ }
1485+
1486+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
1487+ defer env .CleanUp ()
1488+
1489+ envVar := cli .GetDefaultEnv ()
1490+ envVar ["ARDUINO_ENABLE_UNSAFE_LIBRARY_INSTALL" ] = "true"
1491+
1492+ libInstallDir := cli .SketchbookDir ().Join ("libraries" , "WiFi101" )
1493+ // Verifies library is not installed
1494+ require .NoDirExists (t , libInstallDir .String ())
1495+
1496+ // Clone repository locally
1497+ gitUrl := "https://github.com/arduino-libraries/WiFi101.git"
1498+ repoDir := cli .SketchbookDir ().Join ("WiFi101" )
1499+ _ , err := git .PlainClone (repoDir .String (), false , & git.CloneOptions {
1500+ URL : gitUrl ,
1501+ })
1502+ require .NoError (t , err )
1503+
1504+ _ , _ , err = cli .RunWithCustomEnv (envVar , "lib" , "install" , "--git-url" , "file:///" + repoDir .String ())
1505+ require .NoError (t , err )
1506+
1507+ // Verifies library is installed
1508+ require .DirExists (t , libInstallDir .String ())
1509+ }
0 commit comments