@@ -577,3 +577,90 @@ func TestSetSliceWithSingleArgument(t *testing.T) {
577577 require .NoError (t , err )
578578 requirejson .Query (t , stdout , ".board_manager | .additional_urls" , "[\" https://example.com/yet_another_package_example_index.json\" ]" )
579579}
580+
581+ func TestSetSliceWithMultipleArguments (t * testing.T ) {
582+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
583+ defer env .CleanUp ()
584+
585+ // Create a config file
586+ _ , _ , err := cli .Run ("config" , "init" , "--dest-dir" , "." )
587+ require .NoError (t , err )
588+
589+ // Verifies default state
590+ stdout , _ , err := cli .Run ("config" , "dump" , "--format" , "json" )
591+ require .NoError (t , err )
592+ requirejson .Query (t , stdout , ".board_manager | .additional_urls" , "[]" )
593+
594+ // Set some URLs in the list
595+ urls := [7 ]string {
596+ "https://example.com/first_package_index.json" ,
597+ "https://example.com/second_package_index.json" ,
598+ }
599+ _ , _ , err = cli .Run ("config" , "set" , "board_manager.additional_urls" , urls [0 ], urls [1 ])
600+ require .NoError (t , err )
601+
602+ // Verifies value is changed
603+ stdout , _ , err = cli .Run ("config" , "dump" , "--format" , "json" )
604+ require .NoError (t , err )
605+ requirejson .Query (t , stdout , ".board_manager | .additional_urls | length" , "2" )
606+ requirejson .Contains (t , stdout , `
607+ {
608+ "board_manager": {
609+ "additional_urls": [
610+ "https://example.com/first_package_index.json",
611+ "https://example.com/second_package_index.json"
612+ ]
613+ }
614+ }` )
615+
616+ // Set some URLs in the list
617+ urls = [7 ]string {
618+ "https://example.com/third_package_index.json" ,
619+ "https://example.com/fourth_package_index.json" ,
620+ }
621+ _ , _ , err = cli .Run ("config" , "set" , "board_manager.additional_urls" , urls [0 ], urls [1 ])
622+ require .NoError (t , err )
623+
624+ // Verifies previous value is overwritten
625+ stdout , _ , err = cli .Run ("config" , "dump" , "--format" , "json" )
626+ require .NoError (t , err )
627+ requirejson .Query (t , stdout , ".board_manager | .additional_urls | length" , "2" )
628+ requirejson .Contains (t , stdout , `
629+ {
630+ "board_manager": {
631+ "additional_urls": [
632+ "https://example.com/third_package_index.json",
633+ "https://example.com/fourth_package_index.json"
634+ ]
635+ }
636+ }` )
637+
638+ // Sets a third set of 7 URLs (with only 4 unique values)
639+ urls = [7 ]string {
640+ "https://example.com/first_package_index.json" ,
641+ "https://example.com/second_package_index.json" ,
642+ "https://example.com/first_package_index.json" ,
643+ "https://example.com/fifth_package_index.json" ,
644+ "https://example.com/second_package_index.json" ,
645+ "https://example.com/sixth_package_index.json" ,
646+ "https://example.com/first_package_index.json" ,
647+ }
648+ _ , _ , err = cli .Run ("config" , "set" , "board_manager.additional_urls" , urls [0 ], urls [1 ], urls [2 ], urls [3 ], urls [4 ], urls [5 ], urls [6 ])
649+ require .NoError (t , err )
650+
651+ // Verifies all unique values exist in config
652+ stdout , _ , err = cli .Run ("config" , "dump" , "--format" , "json" )
653+ require .NoError (t , err )
654+ requirejson .Query (t , stdout , ".board_manager | .additional_urls | length" , "4" )
655+ requirejson .Contains (t , stdout , `
656+ {
657+ "board_manager": {
658+ "additional_urls": [
659+ "https://example.com/first_package_index.json",
660+ "https://example.com/second_package_index.json",
661+ "https://example.com/fifth_package_index.json",
662+ "https://example.com/sixth_package_index.json"
663+ ]
664+ }
665+ }` )
666+ }
0 commit comments