feat: add production/enabled flags to environments, drop status enum
Environments now have: - production (bool): prod vs non-prod resource allocation - enabled (bool): disabled blocks new deployments Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -74,7 +74,7 @@ class EnvironmentAdminControllerIT extends AbstractPostgresIT {
|
||||
@Test
|
||||
void createEnvironment_asAdmin_returns201() throws Exception {
|
||||
String json = """
|
||||
{"slug": "staging", "displayName": "Staging"}
|
||||
{"slug": "staging", "displayName": "Staging", "production": false}
|
||||
""";
|
||||
|
||||
ResponseEntity<String> response = restTemplate.exchange(
|
||||
@@ -86,10 +86,40 @@ class EnvironmentAdminControllerIT extends AbstractPostgresIT {
|
||||
JsonNode body = objectMapper.readTree(response.getBody());
|
||||
assertThat(body.path("slug").asText()).isEqualTo("staging");
|
||||
assertThat(body.path("displayName").asText()).isEqualTo("Staging");
|
||||
assertThat(body.path("status").asText()).isEqualTo("ACTIVE");
|
||||
assertThat(body.path("production").asBoolean()).isFalse();
|
||||
assertThat(body.path("enabled").asBoolean()).isTrue();
|
||||
assertThat(body.has("id")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateEnvironment_asAdmin_returns200() throws Exception {
|
||||
// Create an environment first
|
||||
String createJson = """
|
||||
{"slug": "update-test", "displayName": "Before", "production": false}
|
||||
""";
|
||||
ResponseEntity<String> createResponse = restTemplate.exchange(
|
||||
"/api/v1/admin/environments", HttpMethod.POST,
|
||||
new HttpEntity<>(createJson, securityHelper.authHeaders(adminJwt)),
|
||||
String.class);
|
||||
JsonNode created = objectMapper.readTree(createResponse.getBody());
|
||||
String envId = created.path("id").asText();
|
||||
|
||||
// Update it
|
||||
String updateJson = """
|
||||
{"displayName": "After", "production": true, "enabled": false}
|
||||
""";
|
||||
ResponseEntity<String> response = restTemplate.exchange(
|
||||
"/api/v1/admin/environments/" + envId, HttpMethod.PUT,
|
||||
new HttpEntity<>(updateJson, securityHelper.authHeaders(adminJwt)),
|
||||
String.class);
|
||||
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
JsonNode body = objectMapper.readTree(response.getBody());
|
||||
assertThat(body.path("displayName").asText()).isEqualTo("After");
|
||||
assertThat(body.path("production").asBoolean()).isTrue();
|
||||
assertThat(body.path("enabled").asBoolean()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void createEnvironment_duplicateSlug_returns400() {
|
||||
String json = """
|
||||
|
||||
Reference in New Issue
Block a user