From dcab6e715813c1c88e656dccedccda92280ed300 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Mon, 30 Mar 2015 16:29:35 -0400 Subject: [PATCH] Add some failing tests for ConfigDocument.removeValue --- .../config/impl/ConfigDocumentTest.scala | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/config/src/test/scala/com/typesafe/config/impl/ConfigDocumentTest.scala b/config/src/test/scala/com/typesafe/config/impl/ConfigDocumentTest.scala index ea2ffea0..5ba9ad2e 100644 --- a/config/src/test/scala/com/typesafe/config/impl/ConfigDocumentTest.scala +++ b/config/src/test/scala/com/typesafe/config/impl/ConfigDocumentTest.scala @@ -226,6 +226,30 @@ class ConfigDocumentTest extends TestUtils { assertEquals("""{"a": "b" }""", configDoc.removeValue("c").render()) } + @Test + def configDocumentRemoveMultiple { + val origText = "a { b: 42 }, a.b = 43, a { b: { c: 44 } }" + val configDoc = ConfigDocumentFactory.parseString(origText) + val removed = configDoc.removeValue("a.b") + assertEquals("a { }, a { b: { } }", removed.render()) + } + + @Test + def configDocumentRemoveOverridden { + val origText = "a { b: 42 }, a.b = 43, a { b: { c: 44 }, a : 57 }" + val configDoc = ConfigDocumentFactory.parseString(origText) + val removed = configDoc.removeValue("a.b") + assertEquals("a { }, a : 57", removed.render()) + } + + @Test + def configDocumentRemoveNested { + val origText = "a { b: 42 }, a.b = 43, a { b: { c: 44 } }" + val configDoc = ConfigDocumentFactory.parseString(origText) + val removed = configDoc.removeValue("a.b.c") + assertEquals("a { b: 42 }, a.b = 43, a { b: { } }", removed.render()) + } + @Test def configDocumentArrayFailures { // Attempting a replace on a ConfigDocument parsed from an array throws an error