forked from pkgxdev/pkgx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,65 @@ | ||
import { assert } from "deno/testing/asserts.ts" | ||
import { createTestHarness } from "./testUtils.ts" | ||
import SemVer from "../../src/utils/semver.ts" | ||
import Path from "path" | ||
|
||
Deno.test("update package", { sanitizeResources: false, sanitizeOps: false }, async () => { | ||
const {run, TEA_PREFIX } = await createTestHarness() | ||
|
||
await run(["+sqlite.org=3.39.4"]) | ||
await run(["+sqlite.org=3.39.4"]) | ||
|
||
const expected = TEA_PREFIX.join("sqlite.org").join("v3.39.4") | ||
assert(expected.exists(), "sqlite.org should exist") | ||
|
||
await run(["-S", "+sqlite.org"]) | ||
await run(["-S", "+sqlite.org"]) | ||
|
||
const newVersionLink = TEA_PREFIX.join("sqlite.org").join("v*") | ||
assert(newVersionLink.isSymlink()) | ||
const newVersion = newVersionLink.readlink().basename() | ||
|
||
assert(new SemVer(newVersion).gt(new SemVer("3.39.4"))) | ||
}) | ||
|
||
Deno.test("sync without git on path", { sanitizeResources: false, sanitizeOps: false }, async () => { | ||
Deno.test("sync and update without git on path", { sanitizeResources: false, sanitizeOps: false }, async () => { | ||
const {run, TEA_PREFIX } = await createTestHarness({sync: false}) | ||
|
||
// empty path so tea can't find git | ||
await run(["-S", "+zlib.net"], { env: { PATH: "" }}) | ||
await run(["-S", "+zlib.net"], { env: { PATH: "" }}) | ||
|
||
const expected = TEA_PREFIX.join("zlib.net") | ||
assert(expected.exists(), "zlib.net should exist") | ||
|
||
// update shouldn't go through | ||
// FIXME: test for dispaying the proper warning | ||
await run(["-S", "+zlib.net"], { env: { PATH: "" }}) | ||
// allows us to verify that the subsequent update works | ||
TEA_PREFIX.join("tea.xyz/var/pantry/projects/zlib.net").rm({ recursive: true }) | ||
|
||
await run(["-S", "+zlib.net"], { env: { PATH: "" }}) | ||
}) | ||
|
||
Deno.test("sync without git then update with git", { sanitizeResources: false, sanitizeOps: false }, async () => { | ||
const {run, TEA_PREFIX } = await createTestHarness({sync: false}) | ||
|
||
// empty path so tea can't find git | ||
await run(["-S", "+zlib.net"], { env: { PATH: "" }}) | ||
|
||
const expected = TEA_PREFIX.join("zlib.net") | ||
assert(expected.exists(), "zlib.net should exist") | ||
|
||
// allows us to verify that the subsequent update works | ||
TEA_PREFIX.join("tea.xyz/var/pantry/projects/zlib.net").rm({ recursive: true }) | ||
|
||
await run(["-S", "+zlib.net"]) | ||
}) | ||
|
||
Deno.test("sync with git then update without", { sanitizeResources: false, sanitizeOps: false }, async () => { | ||
const {run, TEA_PREFIX } = await createTestHarness({sync: false}) | ||
|
||
await run(["-S", "+zlib.net"]) | ||
|
||
const expected = TEA_PREFIX.join("zlib.net") | ||
assert(expected.exists(), "zlib.net should exist") | ||
|
||
// allows us to verify that the subsequent update works | ||
TEA_PREFIX.join("tea.xyz/var/pantry/projects/zlib.net").rm({ recursive: true }) | ||
|
||
await run(["-S", "+zlib.net"], { env: { PATH: "" }}) | ||
}) |