mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 14:15:24 +00:00
fix: show disk usage for the mount being browsed (#1347)
This commit is contained in:
1 parent
e3eada899c
commit
da588f8fa1
3 files changed
+56
-3
No files matched your search
@@ -0,0 +1,35 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
mountForPath,
|
||||
type DiskFilesystem,
|
||||
} from "../../src/frontend/disk-info";
|
||||
|
||||
function fs(mount: string): DiskFilesystem {
|
||||
return {
|
||||
filesystem: mount,
|
||||
type: "ext4",
|
||||
mount,
|
||||
percent: 10,
|
||||
usedHuman: "1G",
|
||||
totalHuman: "10G",
|
||||
availableHuman: "9G",
|
||||
usedBytes: 1,
|
||||
totalBytes: 10,
|
||||
availableBytes: 9,
|
||||
};
|
||||
}
|
||||
|
||||
describe("mountForPath", () => {
|
||||
const list = [fs("/"), fs("/volume1"), fs("/volume10")];
|
||||
|
||||
it("picks the deepest mount that holds the path", () => {
|
||||
expect(mountForPath(list, "/volume1/share")?.mount).toBe("/volume1");
|
||||
expect(mountForPath(list, "/volume10")?.mount).toBe("/volume10");
|
||||
expect(mountForPath(list, "/etc")?.mount).toBe("/");
|
||||
});
|
||||
|
||||
it("returns null without a path or mounts", () => {
|
||||
expect(mountForPath(list, null)).toBeNull();
|
||||
expect(mountForPath([], "/etc")).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user