Skip to content

Commit

Permalink
Verify sync with and without git
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Apr 26, 2023
1 parent 0c7244f commit 4b2c03a
Showing 1 changed file with 41 additions and 10 deletions.
51 changes: 41 additions & 10 deletions tests/functional/sync.test.ts
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: "" }})
})

0 comments on commit 4b2c03a

Please sign in to comment.