feat: Ollama models command, with load/pull/delete and unload (#16)
This commit was merged in pull request #16.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
errorMessage,
|
||||
formatBytes,
|
||||
formatRelativeTime,
|
||||
recencyGroup,
|
||||
titleFromPrompt,
|
||||
@@ -98,3 +99,35 @@ describe("errorMessage", () => {
|
||||
expect(typeof errorMessage(circular)).toBe("string");
|
||||
});
|
||||
});
|
||||
|
||||
describe("formatBytes", () => {
|
||||
it("matches what `ollama list` prints for the same bytes", () => {
|
||||
// Captured from this machine: `ollama list` shows ornith-1.5:9b as 6.6 GB,
|
||||
// and a size that disagreed with the terminal would read as our bug.
|
||||
expect(formatBytes(6_550_813_657)).toBe("6.6 GB");
|
||||
});
|
||||
|
||||
it("keeps small counts in bytes", () => {
|
||||
expect(formatBytes(0)).toBe("0 B");
|
||||
expect(formatBytes(326)).toBe("326 B");
|
||||
expect(formatBytes(999)).toBe("999 B");
|
||||
});
|
||||
|
||||
it("steps up one unit at a time", () => {
|
||||
expect(formatBytes(1_500)).toBe("1.5 kB");
|
||||
expect(formatBytes(2_500_000)).toBe("2.5 MB");
|
||||
expect(formatBytes(3_000_000_000_000)).toBe("3.0 TB");
|
||||
});
|
||||
|
||||
it("stops at terabytes rather than inventing a unit", () => {
|
||||
expect(formatBytes(9_000_000_000_000_000)).toBe("9000.0 TB");
|
||||
});
|
||||
|
||||
it("has no answer for a size that is absent or nonsense", () => {
|
||||
// undefined rather than "NaN B", so a caller leaves the field out.
|
||||
expect(formatBytes(undefined)).toBeUndefined();
|
||||
expect(formatBytes(-1)).toBeUndefined();
|
||||
expect(formatBytes(Number.NaN)).toBeUndefined();
|
||||
expect(formatBytes(Number.POSITIVE_INFINITY)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user