@@ -25,6 +25,8 @@ import (
2525 "github.com/arduino/go-paths-helper"
2626 "github.com/stretchr/testify/require"
2727 "go.bug.st/testifyjson/requirejson"
28+ "gopkg.in/src-d/go-git.v4"
29+ "gopkg.in/src-d/go-git.v4/plumbing"
2830)
2931
3032func TestCorrectHandlingOfPlatformVersionProperty (t * testing.T ) {
@@ -386,3 +388,32 @@ func TestCoreUpdateWithLocalUrl(t *testing.T) {
386388 require .NoError (t , err )
387389 require .Contains (t , string (stdout ), "Downloading index: test_index.json downloaded" )
388390}
391+
392+ func TestCoreSearchManuallyInstalledCoresNotPrinted (t * testing.T ) {
393+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
394+ defer env .CleanUp ()
395+
396+ _ , _ , err := cli .Run ("core" , "update-index" )
397+ require .NoError (t , err )
398+
399+ // Verifies only cores in board manager are shown
400+ stdout , _ , err := cli .Run ("core" , "search" , "--format" , "json" )
401+ require .NoError (t , err )
402+ requirejson .Query (t , stdout , "length > 0" , "true" )
403+ oldJson := stdout
404+
405+ // Manually installs a core in sketchbooks hardware folder
406+ gitUrl := "https://github.com/arduino/ArduinoCore-avr.git"
407+ repoDir := cli .SketchbookDir ().Join ("hardware" , "arduino-beta-development" , "avr" )
408+ _ , err = git .PlainClone (repoDir .String (), false , & git.CloneOptions {
409+ URL : gitUrl ,
410+ ReferenceName : plumbing .NewTagReferenceName ("1.8.3" ),
411+ })
412+ require .NoError (t , err )
413+
414+ // Verifies manually installed core is not shown
415+ stdout , _ , err = cli .Run ("core" , "search" , "--format" , "json" )
416+ require .NoError (t , err )
417+ requirejson .NotContains (t , stdout , `[{"id": "arduino-beta-development:avr"}]` )
418+ require .Equal (t , oldJson , stdout )
419+ }
0 commit comments