@autorest/test-utils
Version:
Set of testing utils that are used across packages
26 lines (24 loc) • 677 B
text/typescript
import { DataHandle, getLineIndices } from "@azure-tools/datastore";
/**
* Create a data handle from some string content.
* @param content Content of the file
* @returns DataHandle.
*/
export function createDataHandle(content: string, props: { name?: string } = {}): DataHandle {
const name = props.name ?? "test-generated";
const key = name.includes("://") ? name : `mem://${name}`;
return new DataHandle(
key,
{
status: "loaded",
name,
identity: [name],
artifactType: "",
cached: content,
lineIndices: getLineIndices(content),
positionSourceMap: undefined,
pathSourceMap: undefined,
},
false,
);
}