fix: 修复 OSS 删除与历史筛选
This commit is contained in:
@@ -173,10 +173,11 @@ def test_delete_completed_task_removes_remote_artifacts(client, tmp_config):
|
||||
from backend.database import SessionLocal
|
||||
from backend.models import Task
|
||||
|
||||
oss_url = "https://files.example.com/test/iOS/1_2_0_0_0_main.html"
|
||||
task = Task(
|
||||
id="completed-task", app_id="1", app_name="测试App", build_type="Ad_Hoc",
|
||||
scheme_id="1", scheme_name="readoor31", branch="main", status="completed",
|
||||
oss_url="https://files.example.com/test/iOS/1_2_0_0_0_main.html",
|
||||
oss_url=oss_url,
|
||||
config_json=json.dumps({"APPID": "1", "VERSION": "2.0.0.0", "SOURCE_BRANCH": "main", "BUILD_TYPE": "Ad_Hoc", "OSS_FLODER": "test"}),
|
||||
)
|
||||
db = SessionLocal()
|
||||
@@ -189,6 +190,7 @@ def test_delete_completed_task_removes_remote_artifacts(client, tmp_config):
|
||||
|
||||
assert resp.status_code == 200
|
||||
delete.assert_called_once()
|
||||
assert delete.call_args.args[2] == oss_url
|
||||
assert client.get("/api/tasks/completed-task").status_code == 404
|
||||
|
||||
|
||||
|
||||
@@ -97,3 +97,25 @@ def test_delete_adhoc_artifacts_deletes_all_remote_files():
|
||||
"readoor/iOS/100_2_0_0_0_main_adhoc.html",
|
||||
"readoor/iOS/100_2_0_0_0_main_adhoc.png",
|
||||
]
|
||||
|
||||
|
||||
def test_delete_uses_saved_url_for_legacy_artifact_name():
|
||||
# 旧任务已有 SOURCE_BRANCH 快照,但上传时仍采用未带分支的旧命名。
|
||||
# 不能再根据当前命名规则推算,否则 OSS 会对不存在的键返回成功。
|
||||
config = {
|
||||
"APPID": "100", "VERSION": "2.0.0.0", "SOURCE_BRANCH": "main",
|
||||
"BUILD_TYPE": "Ad_Hoc", "OSS_FLODER": "readoor",
|
||||
}
|
||||
with patch("backend.services.distribution._delete_oss") as delete:
|
||||
delete_published_artifacts(
|
||||
config,
|
||||
{"mode": "oss", "oss": {"base_url": "https://files.example.com"}},
|
||||
"https://files.example.com/readoor/iOS/100_2_0_0_0.html",
|
||||
)
|
||||
|
||||
assert delete.call_args.args[1] == [
|
||||
"readoor/iOS/100_2_0_0_0.ipa",
|
||||
"readoor/iOS/100_2_0_0_0.plist",
|
||||
"readoor/iOS/100_2_0_0_0.html",
|
||||
"readoor/iOS/100_2_0_0_0.png",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user