func run()

in Sources/PackageRegistryCompatibilityTestSuite/APITests/LookupPackageIdentifiers.swift [25:54]


    func run() async {
        for expectation in self.configuration.urls {
            self.log.append(await self.run(lookupURL: expectation.url, expectation: expectation))
            // Case-insensitivity
            self.log.append(await self.run(lookupURL: expectation.url.flipcased, expectation: expectation))
        }

        for url in self.configuration.unknownURLs {
            self.log.append(await TestCase(name: "Lookup package identifiers for unknown URL \(url)") { testCase in
                let url = "\(self.registryURL)/identifiers?url=\(url)"

                testCase.mark("HTTP request: GET \(url)")
                let response = try await self.get(url: url, mediaType: .json)

                // 4.4 Server should return 404 if URL is not recognized
                testCase.mark("HTTP response status")
                guard response.status == .notFound else {
                    throw TestError("Expected HTTP status code 404 but got \(response.status.code)")
                }

                // 3.3 Server should communicate errors using "problem details" object
                testCase.mark("Response body")
                if response.body == nil {
                    testCase.warning("Response should include problem details")
                }
            })
        }

        self.printLog()
    }