2023-03-31 18:23:15 +00:00
|
|
|
import {cliTest,createAuthority,createBond,createRecord} from './helper';
|
2023-03-24 11:32:38 +00:00
|
|
|
|
2023-03-27 06:49:33 +00:00
|
|
|
const args= "name ";
|
2023-03-31 18:23:15 +00:00
|
|
|
const name=`laconic-${Date.now()}`;
|
2023-03-27 06:49:33 +00:00
|
|
|
const crn=`crn://${name}/app/test`;
|
2023-03-24 11:32:38 +00:00
|
|
|
|
|
|
|
var recordId: string;
|
2023-03-31 18:23:15 +00:00
|
|
|
var bondId: string;
|
2023-03-24 11:32:38 +00:00
|
|
|
|
|
|
|
describe("test names",() => {
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2023-03-26 20:12:52 +00:00
|
|
|
// get bond id
|
2023-03-31 18:23:15 +00:00
|
|
|
bondId = createBond("aphoton","10000000")
|
2023-03-26 20:12:52 +00:00
|
|
|
|
2023-03-24 11:32:38 +00:00
|
|
|
// get record id
|
2023-03-26 20:12:52 +00:00
|
|
|
recordId=createRecord("./test/examples/watcher.yml",bondId)
|
2023-03-27 06:49:33 +00:00
|
|
|
|
|
|
|
// reserve authority
|
2023-03-31 18:23:15 +00:00
|
|
|
createAuthority(name)
|
2023-03-27 06:49:33 +00:00
|
|
|
|
|
|
|
// set authority bond
|
2023-03-31 18:23:15 +00:00
|
|
|
const resp=cliTest("authority bond set "+name+" "+bondId);
|
|
|
|
expect(resp).toBeDefined();
|
|
|
|
expect(resp.success).toBeTruthy();
|
2023-03-24 11:32:38 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it("set name",async ()=>{
|
2023-03-27 06:49:33 +00:00
|
|
|
const resp=cliTest(args+"set "+crn+" "+recordId);
|
2023-03-31 18:23:15 +00:00
|
|
|
expect(resp).toBeDefined();
|
|
|
|
expect(resp.success).toBeTruthy();
|
2023-03-24 11:32:38 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("lookup name",async ()=>{
|
2023-03-27 06:49:33 +00:00
|
|
|
const resp=cliTest(args+"lookup "+ crn);
|
2023-03-31 18:23:15 +00:00
|
|
|
expect(resp).toBeDefined();
|
|
|
|
expect(resp[0].latest.id).toEqual(recordId)
|
2023-03-24 11:32:38 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("resolve name",async ()=>{
|
2023-03-27 06:49:33 +00:00
|
|
|
const resp=cliTest(args+"resolve "+crn);
|
2023-03-31 18:23:15 +00:00
|
|
|
expect(resp).toBeDefined();
|
|
|
|
expect(resp[0].id).toEqual(recordId)
|
2023-03-24 11:32:38 +00:00
|
|
|
});
|
|
|
|
|
2023-03-31 18:23:15 +00:00
|
|
|
it("delete name",async ()=>{
|
2023-03-27 06:49:33 +00:00
|
|
|
const resp=cliTest(args+"delete "+crn);
|
2023-03-31 18:23:15 +00:00
|
|
|
expect(resp).toBeDefined();
|
|
|
|
expect(resp.success).toBeTruthy();
|
|
|
|
|
|
|
|
const resolve=cliTest(args+"resolve "+crn);
|
|
|
|
expect(resolve).toBeDefined();
|
|
|
|
expect(resolve[0]).toBeNull();
|
2023-03-24 11:32:38 +00:00
|
|
|
});
|
|
|
|
});
|