fix
This commit is contained in:
+57
-2
@@ -633,10 +633,16 @@ class AdminWorkflowTest {
|
||||
JsonNode blocked = request(signed(get("/admin-api/project-imports/" + code)), 200).path("data");
|
||||
assertThat(blocked.path("status").asText()).isEqualTo("REVIEW");
|
||||
assertThat(blocked.path("errorCode").asText()).isEqualTo("CLEANUP_REPOSITORY_UNSAFE");
|
||||
assertThat(blocked.path("canRetry").asBoolean()).isFalse();
|
||||
assertThat(blocked.path("canRetry").asBoolean()).isTrue();
|
||||
assertThat(blocked.path("retryMessage").asText()).contains("手工删除");
|
||||
assertThat(gitea.deletions).isZero();
|
||||
assertThat(gitea.migrations).isEqualTo(1);
|
||||
assertThat(gitea.inspect(repoName)).isNotNull();
|
||||
// 再次点击只能触发重新核验,不能绕过归属校验去删除仍存在的仓库。
|
||||
request(signed(post("/admin-api/project-imports/" + code + "/retry")), 202);
|
||||
imports.run(code);
|
||||
assertThat(gitea.deletions).isZero();
|
||||
assertThat(gitea.migrations).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -654,11 +660,60 @@ class AdminWorkflowTest {
|
||||
imports.run(code);
|
||||
JsonNode blocked = request(signed(get("/admin-api/project-imports/" + code)), 200).path("data");
|
||||
assertThat(blocked.path("errorCode").asText()).isEqualTo("CLEANUP_REPOSITORY_REPLACED");
|
||||
assertThat(blocked.path("canRetry").asBoolean()).isFalse();
|
||||
assertThat(blocked.path("canRetry").asBoolean()).isTrue();
|
||||
assertThat(gitea.deletions).isZero();
|
||||
assertThat(gitea.migrations).isEqualTo(before);
|
||||
}
|
||||
|
||||
@Test
|
||||
void manuallyRemovedUnsafeRepositoryCanRetryWithoutEditingTaskState() throws Exception {
|
||||
JsonNode task = createImport();
|
||||
String code = task.path("taskCode").asText();
|
||||
String repoName = "p_" + task.path("projectCode").asText();
|
||||
gitea.migrationRejected = true;
|
||||
imports.run(code);
|
||||
gitea.migrationDescriptions.remove(repoName); // 旧任务的残留仓库没有任务标识。
|
||||
request(signed(post("/admin-api/project-imports/" + code + "/retry")), 202);
|
||||
imports.run(code);
|
||||
assertThat(request(signed(get("/admin-api/project-imports/" + code)), 200)
|
||||
.path("data").path("errorCode").asText()).isEqualTo("CLEANUP_REPOSITORY_UNSAFE");
|
||||
gitea.deleteRepository(gitea.inspect(repoName).repository()); // 模拟管理员手工删除。
|
||||
JsonNode refreshed = request(signed(get("/admin-api/project-imports/" + code)), 200).path("data");
|
||||
assertThat(refreshed.path("canRetry").asBoolean()).isTrue();
|
||||
assertThat(refreshed.path("status").asText()).isEqualTo("REVIEW");
|
||||
gitea.migrationRejected = false;
|
||||
request(signed(post("/admin-api/project-imports/" + code + "/retry")), 202);
|
||||
imports.run(code);
|
||||
JsonNode done = request(signed(get("/admin-api/project-imports/" + code)), 200).path("data");
|
||||
assertThat(done.path("status").asText()).isEqualTo("SUCCEEDED");
|
||||
assertThat(done.path("projectCode")).isEqualTo(task.path("projectCode"));
|
||||
assertThat(gitea.deletions).isEqualTo(1); // 后台没有额外删除任何仓库。
|
||||
assertThat(gitea.migrations).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void manuallyRemovedReplacementCanRetryWithRecordedOldRepositoryIdentity() throws Exception {
|
||||
JsonNode task = createImport();
|
||||
String code = task.path("taskCode").asText();
|
||||
String name = "p_" + task.path("projectCode").asText();
|
||||
gitea.migrationRejected = true;
|
||||
imports.run(code);
|
||||
gitea.migrationRejected = false;
|
||||
gitea.migrate("https://github.com/example/robot.git", name, java.time.Duration.ofSeconds(1),
|
||||
"community-import:" + code);
|
||||
request(signed(post("/admin-api/project-imports/" + code + "/retry")), 202);
|
||||
imports.run(code);
|
||||
assertThat(request(signed(get("/admin-api/project-imports/" + code)), 200)
|
||||
.path("data").path("errorCode").asText()).isEqualTo("CLEANUP_REPOSITORY_REPLACED");
|
||||
gitea.deleteRepository(gitea.inspect(name).repository());
|
||||
request(signed(post("/admin-api/project-imports/" + code + "/retry")), 202);
|
||||
imports.run(code);
|
||||
assertThat(request(signed(get("/admin-api/project-imports/" + code)), 200)
|
||||
.path("data").path("status").asText()).isEqualTo("SUCCEEDED");
|
||||
assertThat(gitea.deletions).isEqualTo(1);
|
||||
assertThat(gitea.migrations).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void cleanupTimeoutCanResumeAfterConfirmingDeletionWithoutDeletingAgain() throws Exception {
|
||||
JsonNode task = createImport();
|
||||
|
||||
Reference in New Issue
Block a user