in Sources/PackageRegistryCompatibilityTestSuite/APITests/ListPackageReleases.swift [64:87]
func run(scope: String, name: String, appendDotJSON: Bool, expectation: Configuration.PackageExpectation) async -> TestCase {
await TestCase(name: "List releases for package \(scope).\(name) (with\(appendDotJSON ? "" : "out") .json in the URI)") { testCase in
let url = "\(self.registryURL)/\(scope)/\(name)\(appendDotJSON ? ".json" : "")"
testCase.mark("HTTP request: GET \(url)")
let response = try await self.get(url: url, mediaType: .json)
// 4.1 Server should return 200 if package is found
testCase.mark("HTTP response status")
guard response.status == .ok else {
throw TestError("Expected HTTP status code 200 but got \(response.status.code)")
}
// 3.5 Server must set "Content-Type" and "Content-Version" headers
self.checkContentTypeHeader(response.headers, expected: .json, for: &testCase)
self.checkContentVersionHeader(response.headers, for: &testCase)
if self.configuration.paginationSupported {
try await self.checkPaginated(response: response, expectation: expectation, for: &testCase)
} else {
try self.checkNonPaginated(response: response, expectation: expectation, for: &testCase)
}
}
}