Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ jobs:
- latest
os:
- ubuntu-latest
- windows-latest
- macOS-latest

steps:
- name: Clone repository
Expand Down
28 changes: 20 additions & 8 deletions fs/unstable_write_file_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,16 @@ Deno.test("writeFile() handles 'create' when writing to a file", async () => {
const encoder = new TextEncoder();
const data = encoder.encode("Hello");

// Rejects with NotFound when file does not initally exist.
await assertRejects(async () => {
await writeFile(testFile, data, { create: false });
}, NotFound);
// Rejects with NotFound/Error when file does not initally exist.
if (platform() === "win32") {
await assertRejects(async () => {
await writeFile(testFile, data, { create: false });
}, Error);
} else {
await assertRejects(async () => {
await writeFile(testFile, data, { create: false });
}, NotFound);
}

// Creates a file that does not initially exist. (This is default behavior).
await writeFile(testFile, data, { create: true });
Expand Down Expand Up @@ -331,10 +337,16 @@ Deno.test("writeFileSync() handles 'create' when writing to a file", () => {
const encoder = new TextEncoder();
const data = encoder.encode("Hello");

// Throws with NotFound when file does not initally exist.
assertThrows(() => {
writeFileSync(testFile, data, { create: false });
}, NotFound);
// Throws with NotFound/Error when file does not initally exist.
if (platform() === "win32") {
assertThrows(() => {
writeFileSync(testFile, data, { create: false });
}, Error);
} else {
assertThrows(() => {
writeFileSync(testFile, data, { create: false });
}, NotFound);
}

// Creates a file that does not initially exist. (This is default behavior).
writeFileSync(testFile, data, { create: true });
Expand Down
Loading