@@ -668,3 +668,47 @@ func TestSetBoolWithMultipleArguments(t *testing.T) {
668
668
require .Error (t , err )
669
669
require .Contains (t , string (stderr ), "Can't set multiple values in key library.enable_unsafe_install" )
670
670
}
671
+
672
+ func TestDelete (t * testing.T ) {
673
+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
674
+ defer env .CleanUp ()
675
+
676
+ // Create a config file
677
+ _ , _ , err := cli .Run ("config" , "init" , "--dest-dir" , "." )
678
+ require .NoError (t , err )
679
+
680
+ // Verifies default state
681
+ stdout , _ , err := cli .Run ("config" , "dump" , "--format" , "json" )
682
+ require .NoError (t , err )
683
+ requirejson .Query (t , stdout , ".library | .enable_unsafe_install" , "false" )
684
+
685
+ // Delete config key
686
+ _ , _ , err = cli .Run ("config" , "delete" , "library.enable_unsafe_install" )
687
+ require .NoError (t , err )
688
+
689
+ // Verifies value is not found, we read directly from file instead of using
690
+ // the dump command since that would still print the deleted value if it has
691
+ // a default
692
+ configFile := cli .WorkingDir ().Join ("arduino-cli.yaml" )
693
+ configLines , err := configFile .ReadFileAsLines ()
694
+ require .NoError (t , err )
695
+ require .NotContains (t , configLines , "enable_unsafe_install" )
696
+
697
+ // Verifies default state
698
+ stdout , _ , err = cli .Run ("config" , "dump" , "--format" , "json" )
699
+ require .NoError (t , err )
700
+ requirejson .Query (t , stdout , ".board_manager | .additional_urls" , "[]" )
701
+
702
+ // Delete config key and sub keys
703
+ _ , _ , err = cli .Run ("config" , "delete" , "board_manager" )
704
+ require .NoError (t , err )
705
+
706
+ // Verifies value is not found, we read directly from file instead of using
707
+ // the dump command since that would still print the deleted value if it has
708
+ // a default
709
+ configFile = cli .WorkingDir ().Join ("arduino-cli.yaml" )
710
+ configLines , err = configFile .ReadFileAsLines ()
711
+ require .NoError (t , err )
712
+ require .NotContains (t , configLines , "additional_urls" )
713
+ require .NotContains (t , configLines , "board_manager" )
714
+ }
0 commit comments