@@ -526,3 +526,61 @@ func TestSetSliceWithSingleArgument(t *testing.T) {
526
526
require .NoError (t , err )
527
527
requirejson .Query (t , stdout , ".board_manager | .additional_urls" , "[\" https://example.com/yet_another_package_example_index.json\" ]" )
528
528
}
529
+
530
+ func TestSetSliceWithMultipleArguments (t * testing.T ) {
531
+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
532
+ defer env .CleanUp ()
533
+
534
+ // Create a config file
535
+ _ , _ , err := cli .Run ("config" , "init" , "--dest-dir" , "." )
536
+ require .NoError (t , err )
537
+
538
+ // Verifies default state
539
+ stdout , _ , err := cli .Run ("config" , "dump" , "--format" , "json" )
540
+ require .NoError (t , err )
541
+ requirejson .Query (t , stdout , ".board_manager | .additional_urls" , "[]" )
542
+
543
+ // Set some URLs in the list
544
+ urls := [2 ]string {
545
+ "https://example.com/first_package_index.json" ,
546
+ "https://example.com/second_package_index.json" ,
547
+ }
548
+ _ , _ , err = cli .Run ("config" , "set" , "board_manager.additional_urls" , urls [0 ], urls [1 ])
549
+ require .NoError (t , err )
550
+
551
+ // Verifies value is changed
552
+ stdout , _ , err = cli .Run ("config" , "dump" , "--format" , "json" )
553
+ require .NoError (t , err )
554
+ requirejson .Query (t , stdout , ".board_manager | .additional_urls | length" , "2" )
555
+ requirejson .Contains (t , stdout , `
556
+ {
557
+ "board_manager": {
558
+ "additional_urls": [
559
+ "https://example.com/first_package_index.json",
560
+ "https://example.com/second_package_index.json"
561
+ ]
562
+ }
563
+ }` )
564
+
565
+ // Set some URLs in the list
566
+ urls = [2 ]string {
567
+ "https://example.com/third_package_index.json" ,
568
+ "https://example.com/fourth_package_index.json" ,
569
+ }
570
+ _ , _ , err = cli .Run ("config" , "set" , "board_manager.additional_urls" , urls [0 ], urls [1 ])
571
+ require .NoError (t , err )
572
+
573
+ // Verifies previous value is overwritten
574
+ stdout , _ , err = cli .Run ("config" , "dump" , "--format" , "json" )
575
+ require .NoError (t , err )
576
+ requirejson .Query (t , stdout , ".board_manager | .additional_urls | length" , "2" )
577
+ requirejson .Contains (t , stdout , `
578
+ {
579
+ "board_manager": {
580
+ "additional_urls": [
581
+ "https://example.com/third_package_index.json",
582
+ "https://example.com/fourth_package_index.json"
583
+ ]
584
+ }
585
+ }` )
586
+ }
0 commit comments