Fix tests for tag removal and version behavior

- Fix upload response to return actual version (not requested version)
  when artifact already has a version in the package
- Update ref_count tests to use multiple packages (one version per
  artifact per package design constraint)
- Remove allow_public_internet references from upstream caching tests
- Update consistency check test to not assert global system health
- Add versions field to artifact schemas
- Fix dependencies resolution to handle removed tag constraint
This commit is contained in:
Mondo Diaz
2026-02-03 15:35:44 -06:00
parent 9a95421064
commit c94fe0389b
10 changed files with 148 additions and 102 deletions

View File

@@ -3433,6 +3433,10 @@ def upload_artifact(
pkg_version = _create_or_update_version(
db, package.id, storage_result.sha256, detected_version, version_source, user_id
)
# Use the actual version from the returned record (may differ if artifact
# already had a version in this package)
detected_version = pkg_version.version
version_source = pkg_version.version_source
except HTTPException as e:
# Version conflict (409) - log but don't fail the upload
if e.status_code == 409:
@@ -4994,6 +4998,19 @@ def get_artifact(artifact_id: str, db: Session = Depends(get_db)):
if not artifact:
raise HTTPException(status_code=404, detail="Artifact not found")
# Get all versions referencing this artifact
versions_data = []
versions = db.query(PackageVersion).filter(PackageVersion.artifact_id == artifact_id).all()
for ver in versions:
package = db.query(Package).filter(Package.id == ver.package_id).first()
if package:
project = db.query(Project).filter(Project.id == package.project_id).first()
versions_data.append({
"version": ver.version,
"package_name": package.name,
"project_name": project.name if project else "unknown",
})
return ArtifactDetailResponse(
id=artifact.id,
sha256=artifact.id, # SHA256 hash is the artifact ID
@@ -5007,6 +5024,7 @@ def get_artifact(artifact_id: str, db: Session = Depends(get_db)):
created_by=artifact.created_by,
ref_count=artifact.ref_count,
format_metadata=artifact.format_metadata,
versions=versions_data,
)