Tests for registry-cli #32
@ -11,6 +11,7 @@
|
|||||||
"@types/js-yaml": "^4.0.5",
|
"@types/js-yaml": "^4.0.5",
|
||||||
"@types/lodash": "^4.14.182",
|
"@types/lodash": "^4.14.182",
|
||||||
"@types/node": "^17.0.25",
|
"@types/node": "^17.0.25",
|
||||||
|
"@types/semver": "^7.3.13",
|
||||||
"@types/yargs": "^17.0.10",
|
"@types/yargs": "^17.0.10",
|
||||||
"jest": "^29.5.0",
|
"jest": "^29.5.0",
|
||||||
"ts-jest": "^29.0.5",
|
"ts-jest": "^29.0.5",
|
||||||
|
@ -1,5 +1,21 @@
|
|||||||
|
import yaml from 'js-yaml'
|
||||||
|
import fs from 'fs'
|
||||||
|
import path from 'path'
|
||||||
|
import semver from 'semver';
|
||||||
|
|
||||||
const { execSync } = require("child_process");
|
const { execSync } = require("child_process");
|
||||||
|
|
||||||
|
export const updateRecord = (filePath: string) => {
|
||||||
|
const resolvedFilePath = path.resolve(process.cwd(), filePath);
|
||||||
|
const file = fs.readFileSync(resolvedFilePath, 'utf-8')
|
||||||
|
const data = yaml.load(file) as any;
|
||||||
|
console.log("Data====",data)
|
||||||
|
|
||||||
|
data.record.version=semver.inc(data.record.version, 'patch');
|
||||||
|
|
||||||
|
fs.writeFileSync(resolvedFilePath, yaml.dump(data));
|
||||||
|
};
|
||||||
|
|
||||||
export const cliTest = (args: any) => {
|
export const cliTest = (args: any) => {
|
||||||
try{
|
try{
|
||||||
return JSON.parse(execSync(`./bin/laconic cns ${args}`));
|
return JSON.parse(execSync(`./bin/laconic cns ${args}`));
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {cliTest,createBond} from './helper';
|
import {cliTest,createBond, updateRecord} from './helper';
|
||||||
|
|
||||||
const args= "record "
|
const args= "record "
|
||||||
const filename = "./test/examples/watcher.yml"
|
const filename = "./test/examples/watcher.yml"
|
||||||
@ -11,20 +11,29 @@ describe("test record",() => {
|
|||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
// get bondId
|
// get bondId
|
||||||
bondId=createBond("aphoton","1000000000")
|
bondId=createBond("aphoton","1000000000")
|
||||||
|
updateRecord(filename)
|
||||||
});
|
});
|
||||||
|
|
||||||
it("publish record",async ()=>{
|
it("publish record",async ()=>{
|
||||||
const resp=cliTest(args+"publish --filename "+filename+" --bond-id "+bondId);
|
const resp=cliTest(args+"publish --filename "+filename+" --bond-id "+bondId);
|
||||||
expect(resp).toBeDefined;
|
expect(resp).toBeDefined();
|
||||||
|
console.log(resp.toString())
|
||||||
|
expect(resp.id).toBeDefined();
|
||||||
|
|
||||||
|
recordId=resp.id
|
||||||
});
|
});
|
||||||
|
|
||||||
it("get record",async ()=>{
|
it("get record",async ()=>{
|
||||||
const resp=cliTest(args+"get --id "+recordId);
|
const resp=cliTest(args+"get --id "+recordId);
|
||||||
expect(resp).toBeDefined;
|
expect(resp).toBeDefined();
|
||||||
|
expect(resp.length).toEqual(1);
|
||||||
|
expect(resp[0].id).toEqual(recordId)
|
||||||
|
expect(resp[0].bondId).toEqual(bondId)
|
||||||
});
|
});
|
||||||
|
|
||||||
it("list records",async ()=>{
|
it("list records",async ()=>{
|
||||||
const resp=cliTest(args+"list");
|
const resp=cliTest(args+"list");
|
||||||
expect(resp).toBeDefined;
|
expect(resp).toBeDefined();
|
||||||
|
expect(resp.length).toBeGreaterThan(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
37
yarn.lock
37
yarn.lock
@ -1200,6 +1200,11 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@types/node" "*"
|
"@types/node" "*"
|
||||||
|
|
||||||
|
"@types/semver@^7.3.13":
|
||||||
|
version "7.3.13"
|
||||||
|
resolved "https://registry.npmjs.org/@types/semver/-/semver-7.3.13.tgz"
|
||||||
|
integrity sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==
|
||||||
|
|
||||||
"@types/stack-utils@^2.0.0":
|
"@types/stack-utils@^2.0.0":
|
||||||
version "2.0.1"
|
version "2.0.1"
|
||||||
resolved "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz"
|
resolved "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz"
|
||||||
@ -1531,7 +1536,16 @@ cborg@^1.5.4, cborg@^1.6.0:
|
|||||||
resolved "https://registry.npmjs.org/cborg/-/cborg-1.9.1.tgz"
|
resolved "https://registry.npmjs.org/cborg/-/cborg-1.9.1.tgz"
|
||||||
integrity sha512-6xKRdJ89ncwEXJGx9rFMRBNp72UqgYSGt2a88rqsvCLda4OuhRlh3xD2nu+ufrw6h9l94K0cnvyD4WEGpKtRtw==
|
integrity sha512-6xKRdJ89ncwEXJGx9rFMRBNp72UqgYSGt2a88rqsvCLda4OuhRlh3xD2nu+ufrw6h9l94K0cnvyD4WEGpKtRtw==
|
||||||
|
|
||||||
chalk@^2.0.0, chalk@^2.4.1:
|
chalk@^2.0.0:
|
||||||
|
version "2.4.2"
|
||||||
|
resolved "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz"
|
||||||
|
integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
|
||||||
|
dependencies:
|
||||||
|
ansi-styles "^3.2.1"
|
||||||
|
escape-string-regexp "^1.0.5"
|
||||||
|
supports-color "^5.3.0"
|
||||||
|
|
||||||
|
chalk@^2.4.1:
|
||||||
version "2.4.2"
|
version "2.4.2"
|
||||||
resolved "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz"
|
resolved "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz"
|
||||||
integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
|
integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
|
||||||
@ -1619,12 +1633,7 @@ concat-map@0.0.1:
|
|||||||
resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz"
|
resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz"
|
||||||
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
|
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
|
||||||
|
|
||||||
convert-source-map@^1.6.0:
|
convert-source-map@^1.6.0, convert-source-map@^1.7.0:
|
||||||
version "1.9.0"
|
|
||||||
resolved "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz"
|
|
||||||
integrity sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==
|
|
||||||
|
|
||||||
convert-source-map@^1.7.0:
|
|
||||||
version "1.9.0"
|
version "1.9.0"
|
||||||
resolved "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz"
|
resolved "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz"
|
||||||
integrity sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==
|
integrity sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==
|
||||||
@ -3044,17 +3053,19 @@ secp256k1@^4.0.1:
|
|||||||
node-addon-api "^2.0.0"
|
node-addon-api "^2.0.0"
|
||||||
node-gyp-build "^4.2.0"
|
node-gyp-build "^4.2.0"
|
||||||
|
|
||||||
semver@^6.0.0:
|
semver@^6.0.0, semver@^6.3.0:
|
||||||
version "6.3.0"
|
version "6.3.0"
|
||||||
resolved "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz"
|
resolved "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz"
|
||||||
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
|
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
|
||||||
|
|
||||||
semver@^6.3.0:
|
semver@^7.3.5:
|
||||||
version "6.3.0"
|
version "7.3.7"
|
||||||
resolved "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz"
|
resolved "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz"
|
||||||
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
|
integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==
|
||||||
|
dependencies:
|
||||||
|
lru-cache "^6.0.0"
|
||||||
|
|
||||||
semver@^7.3.5, semver@7.x:
|
semver@7.x:
|
||||||
version "7.3.7"
|
version "7.3.7"
|
||||||
resolved "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz"
|
resolved "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz"
|
||||||
integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==
|
integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==
|
||||||
|
Loading…
Reference in New Issue
Block a user