Skip to content

Commit

Permalink
Try to fix uploads in pantry.core
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Dec 16, 2022
1 parent 8f9c077 commit 80ae00a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/hooks/useCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const path = (stowage: Stowage) => {
}

function decode(path: Path): Stowed | undefined {
const match = path.basename().match(`^(.*)-([0-9]+\\.[0-9]+\\.[0-9]+)(\\+(.+?)\\+(.+?))?\\.tar\\.[gx]z$`)
const match = path.basename().match(`^(.*)-(\\d+\\.\\d+\\.\\d+.*?)(\\+(.+?)\\+(.+?))?\\.tar\\.[gx]z$`)
if (!match) return
const [_, p, v, host, platform, arch] = match
// Gotta undo the package name manipulation to get the package from the bottle
Expand Down
44 changes: 44 additions & 0 deletions tests/unit/useCache.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { assert, assertEquals, assertFalse, assertThrows } from "deno/testing/asserts.ts"
import useCache from "hooks/useCache.ts"
import Path from "../../src/vendor/Path.ts"

Deno.test("decode", async test => {
await test.step("std", () => {
const stow = useCache().decode(Path.root.join("gnome.org∕glib-2.72.4+darwin+aarch64.tar.xz"))

assertEquals(stow?.type, "bottle")
if (stow?.type != 'bottle') throw new Error() // for type checker

assertEquals(stow.pkg.project, "gnome.org/glib")
assertEquals(stow.pkg.version.toString(), "2.72.4")
assertEquals(stow.compression, 'xz')
assertEquals(stow.host!.arch, "aarch64")
assertEquals(stow.host!.platform, "darwin")
})

await test.step("openssl", () => {
const stow = useCache().decode(Path.root.join("openssl.org-1.1.1s+darwin+aarch64.tar.xz"))

assertEquals(stow?.type, "bottle")
if (stow?.type != 'bottle') throw new Error() // for type checker

assertEquals(stow.pkg.project, "openssl.org")
assertEquals(stow.pkg.version.toString(), "1.1.1s")
assertEquals(stow.compression, 'xz')
assertEquals(stow.host!.arch, "aarch64")
assertEquals(stow.host!.platform, "darwin")
})

await test.step("ghc", () => {
const stow = useCache().decode(Path.root.join("haskell.org-1.2.3.4+darwin+aarch64.tar.xz"))

assertEquals(stow?.type, "bottle")
if (stow?.type != 'bottle') throw new Error() // for type checker

assertEquals(stow.pkg.project, "haskell.org")
assertEquals(stow.pkg.version.toString(), "1.2.3.4")
assertEquals(stow.compression, 'xz')
assertEquals(stow.host!.arch, "aarch64")
assertEquals(stow.host!.platform, "darwin")
})
})

0 comments on commit 80ae00a

Please sign in to comment.