@@ -748,3 +748,47 @@ func TestSetBoolWithMultipleArguments(t *testing.T) {
748
748
require .Error (t , err )
749
749
require .Contains (t , string (stderr ), "Can't set multiple values in key library.enable_unsafe_install" )
750
750
}
751
+
752
+ func TestDelete (t * testing.T ) {
753
+ env , cli := integrationtest .CreateArduinoCLIWithEnvironment (t )
754
+ defer env .CleanUp ()
755
+
756
+ // Create a config file
757
+ _ , _ , err := cli .Run ("config" , "init" , "--dest-dir" , "." )
758
+ require .NoError (t , err )
759
+
760
+ // Verifies default state
761
+ stdout , _ , err := cli .Run ("config" , "dump" , "--format" , "json" )
762
+ require .NoError (t , err )
763
+ requirejson .Query (t , stdout , ".library | .enable_unsafe_install" , "false" )
764
+
765
+ // Delete config key
766
+ _ , _ , err = cli .Run ("config" , "delete" , "library.enable_unsafe_install" )
767
+ require .NoError (t , err )
768
+
769
+ // Verifies value is not found, we read directly from file instead of using
770
+ // the dump command since that would still print the deleted value if it has
771
+ // a default
772
+ configFile := cli .WorkingDir ().Join ("arduino-cli.yaml" )
773
+ configLines , err := configFile .ReadFileAsLines ()
774
+ require .NoError (t , err )
775
+ require .NotContains (t , configLines , "enable_unsafe_install" )
776
+
777
+ // Verifies default state
778
+ stdout , _ , err = cli .Run ("config" , "dump" , "--format" , "json" )
779
+ require .NoError (t , err )
780
+ requirejson .Query (t , stdout , ".board_manager | .additional_urls" , "[]" )
781
+
782
+ // Delete config key and sub keys
783
+ _ , _ , err = cli .Run ("config" , "delete" , "board_manager" )
784
+ require .NoError (t , err )
785
+
786
+ // Verifies value is not found, we read directly from file instead of using
787
+ // the dump command since that would still print the deleted value if it has
788
+ // a default
789
+ configFile = cli .WorkingDir ().Join ("arduino-cli.yaml" )
790
+ configLines , err = configFile .ReadFileAsLines ()
791
+ require .NoError (t , err )
792
+ require .NotContains (t , configLines , "additional_urls" )
793
+ require .NotContains (t , configLines , "board_manager" )
794
+ }
0 commit comments