logical/conformance/model
Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0005-anyfs-posix-conformance FR-003
The reference model the suite holds a view to: a tree of files in memory that follows the rules of a file system as this library states them (a directory is where a file lies below it, an empty directory is kept only by a marker, a file is renamed over a file and never over a directory, a directory is moved whole, an append and a truncate need compare-and-write). The model has no store and no plan: it answers with a value or a code, so that a view over any store that gives a different answer is found, with the seed and the step.
import { PosixModel } from "./model.ts" ;
const m = new PosixModel ({ cas: true , keep: false });
m.writeFile ("/a/b.txt" , new Uint8Array ([1 ])); // { ok: true, value: undefined }
m.readdir ("/a" ); // { ok: true, value: [{ name: "b.txt", type: "file", size: 1 }] } Source: commons/anyfs-posix/src/logical/conformance/model.ts
0 of 4 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.
PosixModelclass no test imports it class PosixModel The model.
Member Type What it is kindOf(p: string) => "dir" | "file" | "none"The kind of a name: for a comparison of the whole tree. stat(p: string) => Answer<{ readonly type: "dir" | "file"; readonly size: number; }>readdir(p: string) => Answer<readonly ModelEntry[]>readFile(p: string) => Answer<Uint8Array<ArrayBufferLike>>writeFile(p: string, data: Uint8Array<ArrayBufferLike>, exclusive?: boolean) => Answer<undefined>touch(p: string) => Answer<undefined>mkdir(p: string, parents?: boolean) => Answer<undefined>rmdir(p: string) => Answer<undefined>unlink(p: string) => Answer<undefined>rename(from: string, to: string) => Answer<undefined>truncate(p: string, length: number) => Answer<undefined>appendFile(p: string, more: Uint8Array<ArrayBufferLike>) => Answer<undefined>removeAll(p: string) => Answer<number>
Answertype no test imports it type Answer <T > = { readonly ok : true ; readonly value : T } | { readonly ok : false ; readonly errno : Errno };What the model answers with: a value, or a code.
ModelEntrytype no test imports it type ModelEntry = { readonly name : string ; readonly type : "file" | "dir" ; readonly size ?: number };One name of a directory in the model.
ModelOptionstype no test imports it type ModelOptions = { readonly cas : boolean ; readonly keep : boolean };What a model of a store is told: whether it compares revisions, and whether it keeps empty directories.