test(deploy): clean up seeded users + document null createdBy placeholder
Fix Issue 1: Add @AfterEach cleanup for alice/bob users in PostgresDeploymentRepositoryCreatedByIT to prevent test leakage (FK order: deployments -> app_versions -> apps, then users). Fix Issue 2: Add comment at first create(..., null) call site in PostgresDeploymentRepositoryIT documenting the null placeholder for pre-V4 rows where createdBy is nullable. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ package com.cameleer.server.app.storage;
|
||||
import com.cameleer.server.app.AbstractPostgresIT;
|
||||
import com.cameleer.server.core.runtime.Deployment;
|
||||
import com.cameleer.server.core.runtime.DeploymentService;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -27,6 +28,7 @@ class PostgresDeploymentRepositoryCreatedByIT extends AbstractPostgresIT {
|
||||
jdbc.update("DELETE FROM deployments");
|
||||
jdbc.update("DELETE FROM app_versions");
|
||||
jdbc.update("DELETE FROM apps");
|
||||
jdbc.update("DELETE FROM users WHERE user_id IN ('alice', 'bob')");
|
||||
|
||||
envId = jdbc.queryForObject(
|
||||
"SELECT id FROM environments WHERE slug = 'default'", UUID.class);
|
||||
@@ -50,6 +52,14 @@ class PostgresDeploymentRepositoryCreatedByIT extends AbstractPostgresIT {
|
||||
versionId, appId);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void cleanup() {
|
||||
jdbc.update("DELETE FROM deployments");
|
||||
jdbc.update("DELETE FROM app_versions");
|
||||
jdbc.update("DELETE FROM apps");
|
||||
jdbc.update("DELETE FROM users WHERE user_id IN ('alice', 'bob')");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createDeployment_persists_createdBy_and_returns_it() {
|
||||
Deployment d = deploymentService.createDeployment(appId, versionId, envId, "alice");
|
||||
|
||||
@@ -65,6 +65,7 @@ class PostgresDeploymentRepositoryIT extends AbstractPostgresIT {
|
||||
null
|
||||
);
|
||||
|
||||
// pre-V4 rows: no creator (createdBy is nullable)
|
||||
UUID deploymentId = repository.create(appId, appVersionId, envId, "test-container", null);
|
||||
repository.saveDeployedConfigSnapshot(deploymentId, snapshot);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user