Replace magic test port 12110 with 0 (#345)

Also introduce constants for some test package SHAs
to make them easier to update.
This commit is contained in:
translatenix
2024-03-20 10:47:28 -07:00
committed by GitHub
parent 2aa60eaf1f
commit dfe85b786e
123 changed files with 469 additions and 469 deletions

View File

@@ -1,8 +1,8 @@
{
"schemaVersion": 1,
"packageUri": "package://localhost:12110/badChecksum@1.0.0",
"packageUri": "package://localhost:0/badChecksum@1.0.0",
"name": "bugs",
"packageZipUrl": "https://localhost:12110/badChecksum@1.0.0/badChecksum@1.0.0.zip",
"packageZipUrl": "https://localhost:0/badChecksum@1.0.0/badChecksum@1.0.0.zip",
"dependencies": {},
"version": "1.0.0",
"packageZipChecksums": {

View File

@@ -1,8 +1,8 @@
{
"schemaVersion": 1,
"packageUri": "package://localhost:12110/badImportsWithinPackage@1.1.0",
"packageUri": "package://localhost:0/badImportsWithinPackage@1.1.0",
"name": "badImportsWithinPackage",
"packageZipUrl": "https://localhost:12110/badImportsWithinPackage@1.0.0/badImportsWithinPackage@1.0.0.zip",
"packageZipUrl": "https://localhost:0/badImportsWithinPackage@1.0.0/badImportsWithinPackage@1.0.0.zip",
"dependencies": {},
"version": "1.0.0",
"packageZipChecksums": {

View File

@@ -1,6 +1,6 @@
{
"schemaVersion": 1,
"packageUri": "package://localhost:12110/badPackagezipUrl@1.1.0",
"packageUri": "package://localhost:0/badPackagezipUrl@1.1.0",
"name": "bugs",
"packageZipUrl": "ftp://wait/a/minute",
"dependencies": {},

View File

@@ -1,13 +1,13 @@
{
"schemaVersion": 1,
"name": "birds",
"packageUri": "package://localhost:12110/birds@0.5.0",
"packageZipUrl": "https://localhost:12110/birds@0.5.0/birds@0.5.0.zip",
"packageUri": "package://localhost:0/birds@0.5.0",
"packageZipUrl": "https://localhost:0/birds@0.5.0/birds@0.5.0.zip",
"dependencies": {
"fruities": {
"uri": "package://localhost:12110/fruit@1.0.5",
"uri": "package://localhost:0/fruit@1.0.5",
"checksums": {
"sha256": "abd173e8a25f5b930b0e34269a441e32c9d95e0b0a715bc6eff918f0afd0688e"
"sha256": "34a15b02346e6acb85da5bd71d8b0738a79008b38a7fc805e5869d9129ad27d2"
}
}
},

View File

@@ -1,9 +1,9 @@
{
"schemaVersion": 1,
"packageUri": "package://localhost:12110/fruit@1.0.5",
"packageUri": "package://localhost:0/fruit@1.0.5",
"name": "fruit",
"version": "1.0.5",
"packageZipUrl": "https://localhost:12110/fruit@1.0.5/fruit@1.0.5.zip",
"packageZipUrl": "https://localhost:0/fruit@1.0.5/fruit@1.0.5.zip",
"dependencies": {},
"packageZipChecksums": {
"sha256": "$computedChecksum"

View File

@@ -1,9 +1,9 @@
{
"schemaVersion": 1,
"packageUri": "package://localhost:12110/fruit@1.1.0",
"packageUri": "package://localhost:0/fruit@1.1.0",
"name": "fruit",
"version": "1.1.0",
"packageZipUrl": "https://localhost:12110/fruit@1.1.0/fruit@1.1.0.zip",
"packageZipUrl": "https://localhost:0/fruit@1.1.0/fruit@1.1.0.zip",
"dependencies": {},
"packageZipChecksums": {
"sha256": "$computedChecksum"

View File

@@ -1,9 +1,9 @@
{
"schemaVersion": 1,
"packageUri": "package://localhost:12110/packageContainingWildcardCharacters@1.0.0",
"packageUri": "package://localhost:0/packageContainingWildcardCharacters@1.0.0",
"name": "packageContainingWildcardCharacters",
"version": "1.0.0",
"packageZipUrl": "https://localhost:12110/packageContainingWildcardCharacters@1.0.0/packageContainingWildcardCharacters@1.0.0.zip",
"packageZipUrl": "https://localhost:0/packageContainingWildcardCharacters@1.0.0/packageContainingWildcardCharacters@1.0.0.zip",
"dependencies": {},
"packageZipChecksums": {
"sha256": "$computedChecksum"

View File

@@ -41,11 +41,15 @@ import org.pkl.commons.deleteRecursively
* * `testPort` Gradle property
*
* If the server isn't already running, it is automatically started.
* 4. Use port `12110` in your test. `HttpClient` will replace this port with the server port.
* 4. Use port `0` in your test. `HttpClient` will replace this port with the server port.
* 4. [Close][close] the server, for example in [AfterAll][org.junit.jupiter.api.AfterAll].
*/
class PackageServer : AutoCloseable {
companion object {
const val BIRDS_SHA = "bfaf5281613d170a740505cc87561041f4e0cad1f0e6938bf94f7609f9a4673d"
const val FRUIT_SHA = "34a15b02346e6acb85da5bd71d8b0738a79008b38a7fc805e5869d9129ad27d2"
const val FRUIT_1_1_SHA = "8d982761d182f2185e4180c82190791d9a60c721cb3393bb2e946fab90131e8c"
fun populateCacheDir(cacheDir: Path) {
val basePath = cacheDir.resolve("package-1/localhost:$PORT")
basePath.deleteRecursively()
@@ -65,7 +69,7 @@ class PackageServer : AutoCloseable {
// Port declared in tests.
// Modified by RequestRewritingClient if testPort is set.
private const val PORT = 12110
private const val PORT = 0
private val packagesDir: Path =
FileTestUtils.rootProjectDir.resolve("pkl-commons-test/build/test-packages")