From 970249000dd8fabedb9593a1a3430c11b4f9f9bb Mon Sep 17 00:00:00 2001 From: Nell Hardcastle Date: Mon, 1 Apr 2024 11:09:51 -0700 Subject: [PATCH] tests(cli): Fix test case on Windows with hardcoded path --- cli/src/deps.ts | 1 + cli/src/worker/git.test.ts | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cli/src/deps.ts b/cli/src/deps.ts index 14cf246d2..2e5f34b5f 100644 --- a/cli/src/deps.ts +++ b/cli/src/deps.ts @@ -42,6 +42,7 @@ export { join } from "https://deno.land/std@0.212.0/path/join.ts" export { extname } from "https://deno.land/std@0.212.0/path/extname.ts" export { basename } from "https://deno.land/std@0.212.0/path/basename.ts" export { dirname } from "https://deno.land/std@0.212.0/path/dirname.ts" +export { SEPARATOR } from "https://deno.land/std@0.221.0/path/mod.ts" // Test suites export { assert, diff --git a/cli/src/worker/git.test.ts b/cli/src/worker/git.test.ts index 39eace547..545c40b9a 100644 --- a/cli/src/worker/git.test.ts +++ b/cli/src/worker/git.test.ts @@ -1,10 +1,10 @@ import { annexRelativePath, hashDirLower, hashDirMixed } from "./git.ts" -import { assertArrayIncludes, assertEquals, git, join, walk } from "../deps.ts" +import { assertArrayIncludes, assertEquals, git, join, walk, SEPARATOR } from "../deps.ts" import { addGitFiles } from "../commands/upload.ts" import fs from "node:fs" Deno.test("annexRelativePath() returns appropriate paths", () => { - assertEquals(annexRelativePath("sub-01/anat/sub-01_T1w.nii.gz"), "../..") + assertEquals(annexRelativePath("sub-01/anat/sub-01_T1w.nii.gz"), join('..', '..')) }) Deno.test("hashDirLower() returns the correct key prefix", async () => { @@ -139,8 +139,8 @@ LICENSE annex.largefiles=nothing`), includeSymlinks: true, }) ) { - const relativePath = walkEntry.path.split(testRepo + "/")[1] - if (relativePath.startsWith(".git/objects/")) { + const relativePath = walkEntry.path.split(testRepo + SEPARATOR)[1] + if (relativePath.startsWith(`.git${SEPARATOR}objects${SEPARATOR}`)) { gitObjects += 1 } else { assertArrayIncludes(expectedFiles, [relativePath])