MCPcopy Index your code
hub / github.com/subquery/subql / testYAML

Function testYAML

packages/cli/src/controller/init-controller.test.ts:20–43  ·  view source on GitHub ↗
(projectPath: string, project: ProjectSpecBase)

Source from the content-addressed store, hash-verified

18} from './init-controller';
19
20async function testYAML(projectPath: string, project: ProjectSpecBase): Promise<{old: Document; new: Document}> {
21 const yamlPath = path.join(`${projectPath}`, `project.yaml`);
22 const manifest = await fs.promises.readFile(yamlPath, 'utf8');
23 const data = parseDocument(manifest);
24
25 const clonedData = data.clone();
26 clonedData.set('description', project.description ?? data.get('description'));
27
28 // network type should be collection
29 const network: any = clonedData.get('network');
30 network.set('endpoint', 'http://def not real endpoint');
31 clonedData.set('version', 'not real version');
32 clonedData.set('name', 'not real name');
33
34 if (isProjectSpecV1_0_0(project)) {
35 network.set('chainId', 'random chainId');
36 } else if (isProjectSpecV0_2_0(project)) {
37 network.set('genesisHash', 'random genesisHash');
38 }
39 return {
40 old: data,
41 new: clonedData,
42 };
43}
44
45async function fileExists(file: string): Promise<boolean> {
46 await fs.promises.access(file, fs.constants.F_OK);

Callers 1

Calls 5

isProjectSpecV1_0_0Function · 0.90
isProjectSpecV0_2_0Function · 0.90
cloneMethod · 0.80
setMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected