diff options
author | Håkon Hallingstad <hakon@yahooinc.com> | 2023-08-02 10:59:51 +0200 |
---|---|---|
committer | Håkon Hallingstad <hakon@yahooinc.com> | 2023-08-02 10:59:51 +0200 |
commit | 0adede88d0aa7bbb7280a5c26a5279fc08246652 (patch) | |
tree | 10f42c2494edde12407bc6a3b7c9a28fb36f20e6 /controller-api/src/test/java/com/yahoo | |
parent | ae86f6951daa412bbad509ff06998bb66b632cae (diff) |
Remove sentinel null valued rules independent of any conditions
Diffstat (limited to 'controller-api/src/test/java/com/yahoo')
-rw-r--r-- | controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/SystemFlagsDataArchiveTest.java | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/SystemFlagsDataArchiveTest.java b/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/SystemFlagsDataArchiveTest.java index a24bed54a8a..f1e356eead2 100644 --- a/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/SystemFlagsDataArchiveTest.java +++ b/controller-api/src/test/java/com/yahoo/vespa/hosted/controller/api/systemflags/v1/SystemFlagsDataArchiveTest.java @@ -146,11 +146,31 @@ public class SystemFlagsDataArchiveTest { Throwable exception = assertThrows(IllegalArgumentException.class, () -> { SystemFlagsDataArchive.fromDirectory(Paths.get("src/test/resources/system-flags-with-unknown-field-name/")); }); - assertTrue(exception.getMessage().contains("flags/my-test-flag/main.prod.us-west-1.json contains unknown non-comment fields: after removing any comment fields the JSON is:\n" + - " {\"id\":\"my-test-flag\",\"rules\":[{\"condition\":[{\"type\":\"whitelist\",\"dimension\":\"hostname\",\"values\":[\"foo.com\"]}],\"value\":\"default\"}]}\n" + - "but deserializing this ended up with a JSON that are missing some of the fields:\n" + - " {\"id\":\"my-test-flag\",\"rules\":[{\"value\":\"default\"}]}\n" + - "See https://git.ouroath.com/vespa/hosted-feature-flags for more info on the JSON syntax")); + assertEquals(""" + flags/my-test-flag/main.prod.us-west-1.json contains unknown non-comment fields or rules with null values: after removing any comment fields the JSON is: + {"id":"my-test-flag","rules":[{"condition":[{"type":"whitelist","dimension":"hostname","values":["foo.com"]}],"value":"default"}]} + but deserializing this ended up with: + {"id":"my-test-flag","rules":[{"value":"default"}]} + These fields may be spelled wrong, or remove them? + See https://git.ouroath.com/vespa/hosted-feature-flags for more info on the JSON syntax + """, + exception.getMessage()); + } + + @Test + void throws_on_null_value() { + Throwable exception = assertThrows(IllegalArgumentException.class, () -> { + SystemFlagsDataArchive.fromDirectory(Paths.get("src/test/resources/system-flags-with-null-value/")); + }); + assertEquals(""" + flags/my-test-flag/main.prod.us-west-1.json contains unknown non-comment fields or rules with null values: after removing any comment fields the JSON is: + {"id":"my-test-flag","rules":[{"conditions":[{"type":"whitelist","dimension":"application","values":["a:b:c"]}],"value":null},{"conditions":[{"type":"whitelist","dimension":"hostname","values":["foo.com"]}],"value":true}]} + but deserializing this ended up with: + {"id":"my-test-flag","rules":[{"conditions":[{"type":"whitelist","dimension":"application","values":["a:b:c"]}]},{"conditions":[{"type":"whitelist","dimension":"hostname","values":["foo.com"]}],"value":true}]} + These fields may be spelled wrong, or remove them? + See https://git.ouroath.com/vespa/hosted-feature-flags for more info on the JSON syntax + """, + exception.getMessage()); } @Test |