From 4b2c03abc6fb7c177be6ef73e05ae73eeac6aa58 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Wed, 26 Apr 2023 11:41:39 -0400 Subject: [PATCH] Verify sync with and without git --- tests/functional/sync.test.ts | 51 ++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/tests/functional/sync.test.ts b/tests/functional/sync.test.ts index f81561b0..e3df0ecc 100644 --- a/tests/functional/sync.test.ts +++ b/tests/functional/sync.test.ts @@ -1,17 +1,18 @@ 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() @@ -19,16 +20,46 @@ Deno.test("update package", { sanitizeResources: false, sanitizeOps: false }, as 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: "" }}) })