@@ -728,3 +728,40 @@ func TestCoreListSortedResults(t *testing.T) {
728728 require .True (t , strings .HasSuffix (platform , strings .TrimLeft (notSortedDeprecated , "[" )))
729729
730730}
731+
732+ func TestCoreListDeprecatedPlatformWithInstalledJson (t * testing.T ) {
733+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
734+ defer env .CleanUp ()
735+
736+ // Set up the server to serve our custom index file
737+ testIndex := paths .New (".." , "testdata" , "test_index.json" )
738+ url := env .HTTPServeFile (8000 , testIndex )
739+
740+ // update custom index
741+ _ , _ , err := cli .Run ("core" , "update-index" , "--additional-urls=" + url .String ())
742+ require .NoError (t , err )
743+
744+ // install some core for testing
745+ _ , _ , err = cli .Run ("core" , "install" , "Package:x86" , "--additional-urls=" + url .String ())
746+ require .NoError (t , err )
747+
748+ installedJsonFile := cli .DataDir ().Join ("packages" , "Package" , "hardware" , "x86" , "1.2.3" , "installed.json" )
749+ require .FileExists (t , installedJsonFile .String ())
750+ lines , err := installedJsonFile .ReadFileAsLines ()
751+ require .NoError (t , err )
752+ var json []byte
753+ for i , v := range lines {
754+ if i != 13 {
755+ json = append (json , []byte (v + "\n " )... )
756+ }
757+ }
758+ err = installedJsonFile .WriteFile (json )
759+ require .NoError (t , err )
760+
761+ // test same behaviour with json output
762+ stdout , _ , err := cli .Run ("core" , "list" , "--additional-urls=" + url .String (), "--format=json" )
763+ require .NoError (t , err )
764+
765+ requirejson .Len (t , stdout , 1 )
766+ requirejson .Query (t , stdout , ".[] | .deprecated" , "true" )
767+ }
0 commit comments