@@ -39,13 +39,13 @@ public void printsErrorIfNoArgumentsGiven() {
3939
4040 @ Test
4141 public void printsErrorIfTwoConflictingOptionsGiven () {
42- app .run (new String [] {"config" , "--get " , "--list" });
42+ app .run (new String [] {"config" , "--delete " , "--list" });
4343 io .assertContains ("Only one of the" );
4444 }
4545
4646 @ Test
4747 public void printsErrorIfThreeConflictingOptionsGiven () {
48- app .run (new String [] {"config" , "--get " , "--list" , "--delete " });
48+ app .run (new String [] {"config" , "--delete " , "--list" , "--get" , "property " });
4949 io .assertContains ("Only one of the" );
5050 }
5151
@@ -58,6 +58,43 @@ public void listsAllProperties() {
5858 io .assertContains ("toilet=wonderland" );
5959 }
6060
61+ @ Test
62+ public void listsAllPropertiesWithExtraArgument () {
63+ props .put ("hello" , "world" );
64+ props .put ("toilet" , "wonderland" );
65+ app .run (new String [] {"config" , "--list" , "abc" });
66+ io .assertContains ("Listing option doesn't take any arguments." );
67+ }
68+
69+ @ Test
70+ public void getProperty () {
71+ props .put ("thing" , "value" );
72+ app .run (new String [] {"config" , "--get" , "thing" });
73+ io .assertContains ("value" );
74+ io .assertAllPromptsUsed ();
75+ }
76+
77+ @ Test
78+ public void getUnexistingProperty () {
79+ app .run (new String [] {"config" , "--get" , "thing" });
80+ io .assertContains ("The property thing doesn't exist" );
81+ io .assertAllPromptsUsed ();
82+ }
83+
84+ @ Test
85+ public void getUnexistingPropertyQuietly () {
86+ app .run (new String [] {"config" , "--get" , "-q" , "thing" });
87+ io .assertNotContains ("The property thing doesn't exist" );
88+ io .assertAllPromptsUsed ();
89+ }
90+
91+ @ Test
92+ public void getPropertyWithExtraArgument () {
93+ props .put ("thing" , "value" );
94+ app .run (new String [] {"config" , "--get" , "thing" , "abc" });
95+ io .assertContains ("There should not be extra arguments when using --get option." );
96+ }
97+
6198 @ Test
6299 public void setsOnePropertyWhenNoOptionsGiven () {
63100 io .addConfirmationPrompt (true );
@@ -122,6 +159,25 @@ public void deletesOnePropertyQuietly() {
122159 io .assertAllPromptsUsed ();
123160 }
124161
162+ @ Test
163+ public void deletesInvalidProperty () {
164+ app .run (new String [] {"config" , "-d" , "property" });
165+ assertTrue (!props .containsKey ("no" ));
166+ io .assertContains ("Key property doesn't exist." );
167+ io .assertAllPromptsUsed ();
168+ }
169+
170+ @ Test
171+ public void deletesOnePropertyWithNoConfirmation () {
172+ io .addConfirmationPrompt (false );
173+ props .put ("no" , "e" );
174+ app .run (new String [] {"config" , "-d" , "no" });
175+ assertTrue (props .containsKey ("no" ));
176+ io .assertContains ("Deleting 1 properties." );
177+ io .assertNotContains ("Deleted key no, was" );
178+ io .assertAllPromptsUsed ();
179+ }
180+
125181 @ Test
126182 public void deletesMultiplePropertiesCorrectly () {
127183 io .addConfirmationPrompt (true );
0 commit comments