Skip to content

Commit

Permalink
Refactor Windows filesystem tests to improve drive accessibility hand…
Browse files Browse the repository at this point in the history
…ling and logging
  • Loading branch information
mceachen committed Nov 9, 2024
1 parent 7416e7c commit 049891a
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/__tests__/windows.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ describe("Filesystem Metadata", () => {
"Mountpoint is required",
);
});
});

describeWindows("Basic Filesystem Operations", () => {
it("should work with valid Windows system paths", async () => {
if (process.env.SystemDrive) {
const systemDrive = process.env.SystemDrive + "\\";
Expand All @@ -83,24 +85,18 @@ describe("Filesystem Metadata", () => {
assertMetadata(metadata);
}
});
});

describeWindows("Basic Filesystem Operations", () => {
let availableDrives: string[] = [];

beforeAll(async () => {
availableDrives = await getMountpoints();
});

it("should return consistent drive information", async () => {
for (const drive of availableDrives.slice(0, 1)) {
const arr = await getMountpoints();
console.log("current mountpoints: " + JSON.stringify(arr))
for (const drive of arr) {
let metadata;
try {
metadata = await getVolumeMetadata(drive);
console.log("fetched metadata: " + JSON.stringify(metadata))
} catch (error) {
// Some drives might not be accessible (e.g., empty DVD drive)
console.log(`Skipping inaccessible drive ${drive}: ${error}`);
return
console.warn(`Skipping inaccessible drive ${drive}: ${error}`);
continue
}
expect(metadata).toBeDefined();
expect(metadata?.mountpoint).toBe(drive);
Expand Down

0 comments on commit 049891a

Please sign in to comment.