Skip to content

Commit fbf1c91

Browse files
committed
Use joins
1 parent ed4a1bb commit fbf1c91

File tree

5 files changed

+52
-31
lines changed

5 files changed

+52
-31
lines changed

src/vt/lib/tests/clone_test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Deno.test({
4242
type: "script",
4343
},
4444
{
45-
path: "nested/folder/data.json",
45+
path: join("nested", "folder", "data.json"),
4646
content: '{"key": "value"}',
4747
type: "file",
4848
},
@@ -111,7 +111,7 @@ Deno.test({
111111

112112
// Verify directory structure was created correctly
113113
const nestedDirExists = await exists(
114-
join(tempDir, "nested/folder"),
114+
join(tempDir, "nested", "folder"),
115115
);
116116
assertEquals(
117117
nestedDirExists,
@@ -131,7 +131,7 @@ Deno.test({
131131
async fn(t) {
132132
await doWithNewVal(async ({ val, branch }) => {
133133
await t.step("test cloning empty directories", async (t) => {
134-
const emptyDirPath = "empty/directory";
134+
const emptyDirPath = join("empty", "directory");
135135

136136
await t.step("create empty directory", async () => {
137137
// Create an empty directory to test explicit directory creation

src/vt/lib/tests/pull_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ Deno.test({
298298
await doWithNewVal(async ({ val, branch }) => {
299299
await doWithTempDir(async (tempDir) => {
300300
// Create nested directories on the server
301-
const nestedDirPath = "parent/child/grandchild";
301+
const nestedDirPath = join("parent", "child", "grandchild");
302302

303303
await t.step("create nested directories on server", async () => {
304304
await sdk.vals.files.create(

src/vt/lib/tests/push_test.ts

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Deno.test({
9494
await valItemExists(
9595
val.id,
9696
branch.id,
97-
"subdir/test.txt",
97+
join("subdir", "test.txt"),
9898
await getLatestVersion(val.id, branch.id),
9999
),
100100
"file should exist in subdir",
@@ -115,7 +115,10 @@ Deno.test({
115115
branchId: branch.id,
116116
});
117117
assertEquals(secondPush.renamed.length, 1);
118-
assertEquals(secondPush.renamed[0].oldPath, "subdir/test.txt");
118+
assertEquals(
119+
secondPush.renamed[0].oldPath,
120+
join("subdir", "test.txt"),
121+
);
119122
assertEquals(secondPush.renamed[0].path, "test.txt");
120123
});
121124

@@ -163,10 +166,10 @@ Deno.test({
163166

164167
// Get original file IDs
165168
const file1 = await sdk.vals.files
166-
.retrieve(val.id, { path: "val/file1.ts", recursive: true })
169+
.retrieve(val.id, { path: join("val", "file1.ts"), recursive: true })
167170
.then((resp) => resp.data[0]);
168171
const file2 = await sdk.vals.files
169-
.retrieve(val.id, { path: "val/file2.ts", recursive: true })
172+
.retrieve(val.id, { path: join("val", "file2.ts"), recursive: true })
170173
.then((resp) => resp.data[0]);
171174

172175
// Delete both files and create two new files with the same content
@@ -202,13 +205,13 @@ Deno.test({
202205
// Verify new files have different IDs than original files
203206
const newFile1 = await sdk.vals.files
204207
.retrieve(val.id, {
205-
path: "val/newfile1.ts",
208+
path: join("val", "newfile1.ts"),
206209
recursive: true,
207210
})
208211
.then((resp) => resp.data[0]);
209212
const newFile2 = await sdk.vals.files
210213
.retrieve(val.id, {
211-
path: "val/newfile2.ts",
214+
path: join("val", "newfile2.ts"),
212215
recursive: true,
213216
})
214217
.then((resp) => resp.data[0]);
@@ -279,7 +282,7 @@ Deno.test({
279282
const fileExistsAtNewPath = await valItemExists(
280283
val.id,
281284
branch.id,
282-
"subdir/moved_file.ts",
285+
join("subdir", "moved_file.ts"),
283286
await getLatestVersion(val.id, branch.id),
284287
);
285288
assert(fileExistsAtNewPath, "file should exist at new location");
@@ -299,7 +302,7 @@ Deno.test({
299302
// Verify the file ID is preserved (same file)
300303
const movedFile = await sdk.vals.files
301304
.retrieve(val.id, {
302-
path: "subdir/moved_file.ts",
305+
path: join("subdir", "moved_file.ts"),
303306
recursive: true,
304307
})
305308
.then((resp) => resp.data[0]);
@@ -410,7 +413,7 @@ Deno.test({
410413
// Get the id of the original file
411414
const originalFile = await sdk.vals.files
412415
.retrieve(val.id, {
413-
path: "val/original.ts",
416+
path: join("val", "original.ts"),
414417
recursive: true,
415418
})
416419
.then((resp) => resp.data[0]);
@@ -431,22 +434,25 @@ Deno.test({
431434

432435
// Verify rename was detected
433436
assertEquals(statusResult.renamed.length, 1);
434-
assertEquals(statusResult.renamed[0].oldPath, "val/original.ts");
435-
assertEquals(statusResult.renamed[0].path, "val/renamed.ts");
437+
assertEquals(
438+
statusResult.renamed[0].oldPath,
439+
join("val", "original.ts"),
440+
);
441+
assertEquals(statusResult.renamed[0].path, join("val", "renamed.ts"));
436442
assertEquals(statusResult.renamed[0].status, "renamed");
437443

438444
// Verify file ID is preserved (same file)
439445
const renamedFile = await sdk.vals.files.retrieve(
440446
val.id,
441-
{ path: "val/renamed.ts", recursive: true },
447+
{ path: join("val", "renamed.ts"), recursive: true },
442448
).then((resp) => resp.data[0]);
443449
assertEquals(originalFile.id, renamedFile.id);
444450

445451
// Verify old file is gone
446452
const oldFileExists = await valItemExists(
447453
val.id,
448454
branch.id,
449-
"val/original.ts",
455+
join("val", "original.ts"),
450456
await getLatestVersion(val.id, branch.id),
451457
);
452458
assert(!oldFileExists, "Old file should not exist after rename");
@@ -481,7 +487,7 @@ Deno.test({
481487
// Get the id of the original file
482488
const originalFile = await sdk.vals.files
483489
.retrieve(val.id, {
484-
path: "val/old.http.ts",
490+
path: join("val", "old.http.ts"),
485491
recursive: true,
486492
})
487493
.then((resp) => resp.data[0]);
@@ -502,16 +508,19 @@ Deno.test({
502508
// Verify rename was detected
503509
assertEquals(statusResult.renamed.length, 1);
504510
assertEquals(statusResult.renamed[0].type, "http");
505-
assertEquals(statusResult.renamed[0].oldPath, "val/old.http.ts");
506-
assertEquals(statusResult.renamed[0].path, "val/new.tsx");
511+
assertEquals(
512+
statusResult.renamed[0].oldPath,
513+
join("val", "old.http.ts"),
514+
);
515+
assertEquals(statusResult.renamed[0].path, join("val", "new.tsx"));
507516
assertEquals(statusResult.renamed[0].status, "renamed");
508517
});
509518

510519
await t.step("verify file content, type, and uuid", async () => {
511520
// Verify file ID is preserved (same file)
512521
const renamedFile = await sdk.vals.files.retrieve(
513522
val.id,
514-
{ path: "val/new.tsx", recursive: true },
523+
{ path: join("val", "new.tsx"), recursive: true },
515524
).then((resp) => resp.data[0]);
516525
assertEquals(originalFile.id, renamedFile.id);
517526

@@ -523,7 +532,7 @@ Deno.test({
523532
val.id,
524533
branch.id,
525534
await getLatestVersion(val.id, branch.id),
526-
"val/new.tsx",
535+
join("val", "new.tsx"),
527536
);
528537

529538
assertEquals(content, "contentt");
@@ -534,7 +543,7 @@ Deno.test({
534543
const oldFileExists = await valItemExists(
535544
val.id,
536545
branch.id,
537-
"val/old.http.ts",
546+
join("val", "old.http.ts"),
538547
await getLatestVersion(val.id, branch.id),
539548
);
540549
assert(!oldFileExists, "Old file should not exist after rename");

src/vt/lib/tests/remix_test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ Deno.test({
175175
await sdk.vals.files.create(
176176
val.id,
177177
{
178-
path: "nested/file.txt",
178+
path: join("nested", "file.txt"),
179179
content: "This is a nested text file",
180180
type: "file",
181181
},
@@ -202,7 +202,7 @@ Deno.test({
202202
);
203203

204204
// Verify nested file was remixed and directory structure preserved
205-
const nestedFilePath = join(destTmpDir, "nested/file.txt");
205+
const nestedFilePath = join(destTmpDir, "nested", "file.txt");
206206
assert(
207207
await exists(nestedFilePath),
208208
"nested file should exist in remixed Val with directory structure preserved",

src/vt/lib/tests/status_test.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,14 @@ Deno.test({
207207

208208
// Push original files to remote
209209
await sdk.vals.files.create(val.id, {
210-
path: "folder/oldA.txt",
210+
path: join("folder", "oldA.txt"),
211211
content: "content",
212212
branch_id: branch.id,
213213
type: "file",
214214
});
215215

216216
await sdk.vals.files.create(val.id, {
217-
path: "folder/oldB.txt",
217+
path: join("folder", "oldB.txt"),
218218
content: "differentContent",
219219
branch_id: branch.id,
220220
type: "file",
@@ -251,20 +251,32 @@ Deno.test({
251251
// Check renamed array - should have the file with unchanged content
252252
assertEquals(statusResult.renamed.length, 1);
253253
assertEquals(statusResult.renamed[0].type, "file");
254-
assertEquals(statusResult.renamed[0].path, "folder/renamedB.txt");
255-
assertEquals(statusResult.renamed[0].oldPath, "folder/oldB.txt");
254+
assertEquals(
255+
statusResult.renamed[0].path,
256+
join("folder", "renamedB.txt"),
257+
);
258+
assertEquals(
259+
statusResult.renamed[0].oldPath,
260+
join("folder", "oldB.txt"),
261+
);
256262
assertEquals(statusResult.renamed[0].status, "renamed");
257263

258264
// Check created array - should have the file with modified content
259265
assertEquals(statusResult.created.length, 1);
260266
assertEquals(statusResult.created[0].type, "file");
261-
assertEquals(statusResult.created[0].path, "folder/renamedA.txt");
267+
assertEquals(
268+
statusResult.created[0].path,
269+
join("folder", "renamedA.txt"),
270+
);
262271
assertEquals(statusResult.created[0].status, "created");
263272

264273
// Check deleted array - should have the old file that was "modified"
265274
assertEquals(statusResult.deleted.length, 1);
266275
assertEquals(statusResult.deleted[0].type, "file");
267-
assertEquals(statusResult.deleted[0].path, "folder/oldA.txt");
276+
assertEquals(
277+
statusResult.deleted[0].path,
278+
join("folder", "oldA.txt"),
279+
);
268280
assertEquals(statusResult.deleted[0].status, "deleted");
269281
});
270282
});

0 commit comments

Comments
 (0)