test(deploy): verify unified TEST and gray environment contracts

This commit is contained in:
2026-10-07 11:17:28 +08:00
parent ec0c06ff88
commit 7ff6512864
4 changed files with 18 additions and 8 deletions
@@ -1,10 +1,12 @@
package com.baiyue.firstleg.client;
import org.junit.jupiter.api.Test;
import org.springframework.util.PropertyPlaceholderHelper;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -23,11 +25,18 @@ class EventBridgeClientDeploymentContractTest {
}
@Test
void testComposeUsesDirectBusinessServiceDns() throws Exception {
void composeUsesDirectBusinessServiceDnsForTestAndGray() throws Exception {
String compose = Files.readString(REPOSITORY_ROOT.resolve("deploy/docker-compose.yml"));
assertTrue(compose.contains("LASTLEG_SERVICE_URL: http://lastleg-service:9303"));
assertTrue(compose.contains("firstleg-test-network"));
String networkName = compose.lines().map(String::strip)
.filter(line -> line.startsWith("name: firstleg-") && line.endsWith("-network"))
.findFirst().orElseThrow().substring("name: ".length());
assertEquals("firstleg-${DEPLOY_ENV:-test}-network", networkName);
var placeholders = new PropertyPlaceholderHelper("${", "}", ":-", false);
assertEquals("firstleg-test-network", placeholders.replacePlaceholders(networkName, key -> null));
assertEquals("firstleg-production-network", placeholders.replacePlaceholders(networkName,
key -> "DEPLOY_ENV".equals(key) ? "production" : null));
assertFalse(compose.contains("event-bridge"));
}
}