Light, fluffy, and always free - The AWS Local Emulator alternative
test(config): accept declared YAML configuration expressions (#6477)
Andre Kurait4f9866418fa5
diff --git a/src/test/java/io/github/hectorvent/floci/config/ServiceConfigYamlCoverageTest.java b/src/test/java/io/github/hectorvent/floci/config/ServiceConfigYamlCoverageTest.javaindex dac89ff9d8..36f5c586a6 100644--- a/src/test/java/io/github/hectorvent/floci/config/ServiceConfigYamlCoverageTest.java+++ b/src/test/java/io/github/hectorvent/floci/config/ServiceConfigYamlCoverageTest.java@@ -11,6 +11,7 @@ import java.nio.file.Path;import java.util.ArrayList;import java.util.List;+import static org.junit.jupiter.api.Assertions.assertFalse;import static org.junit.jupiter.api.Assertions.assertTrue;/**@@ -38,7 +39,7 @@ class ServiceConfigYamlCoverageTest {continue;}String key = StringUtil.skewer(accessor.getName());- if (!services.path(key).path("enabled").isBoolean()) {+ if (!declaresEnabled(services.path(key))) {missing.add(config + " -> floci.services." + key + ".enabled");}}@@ -50,6 +51,32 @@ class ServiceConfigYamlCoverageTest {+ "not count, since it binds to nothing. Missing: " + missing);}+ @Test+ void explicitBooleanAndEnvironmentExpressionDeclareTheToggle() throws IOException {+ for (String value : List.of("true", "false", "${FLOCI_SERVICES_RESOURCE_GROUPS_ENABLED:true}")) {+ JsonNode service = new YAMLMapper().readTree("enabled: " + value);+ assertTrue(declaresEnabled(service), value);+ }+ }++ @Test+ void missingBareNullAndEmptyDeclarationsRemainMissing() throws IOException {+ for (String yaml : List.of("{}", "service:", "service: {}", "service: {enabled: null}",+ "service: {enabled: ''}", "service: {enabled: ' '}",+ "service: {enabled: {}}", "service: {enabled: []}")) {+ JsonNode service = new YAMLMapper().readTree(yaml).path("service");+ assertFalse(declaresEnabled(service), yaml);+ }+ }++ private static boolean declaresEnabled(JsonNode service) {+ JsonNode enabled = service.path("enabled");+ // Config binding validates Boolean values after resolving expressions. This guard only+ // checks that the YAML declares a value instead of relying on the interface fallback.+ return enabled.isValueNode() && !enabled.isNull()+ && (!enabled.isTextual() || !enabled.textValue().isBlank());+ }+/*** Config records without an {@code enabled()} toggle (for example {@code DuckConfig},* which only carries an image and an optional URL) are not services that can be turned