Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@coasys/ad4m-test
Advanced tools
This is a testing library for testing languages for ad4m. This package internally uses ad4m-host (https://github.com/perspect3vism/ad4m/tree/dev/host) to start and interact with ad4m-executor. For more detailed example look go here
npm:
npm install @coasys/ad4m-test
yarn:
yarn add @coasys/ad4m-test
You can write tests like you would with any other testing framework. You can use the helper methods to interact with the ad4m-executor.
example
const { spawnExpressionAgent, spawnLinkAgent } = require('@coasys/ad4m-test/helpers')
describe("Expression", () => {
it("Create Expression", async () => {
const agent = await spawnExpressionAgent()
const exp = await agent.create("{\"name\": \"hello world!\"}");
expect(exp).not.toBeNull()
const fetched = await agent.get(exp);
expect(fetched).not.toBeNull()
})
})
describe("Link", () => {
it("Create Link", async () => {
const agent = await spawnLinkAgent();
const all = await agent.queryLinks({});
expect(all.length).toBe(0)
const link = await agent.addLink({source:"root", predicate: "soic://test", target:"QmYVsrMpiFmV9S7bTWNAkUzSqjRJskQ8g4TWKKwKrHAPqL://QmSsCCtXMDAZXMpyiNLzwjGEU4hLmhG7fphidhEEodQ4Wy"})
const all1 = await agent.queryLinks({});
expect(all1.length).toBe(1)
expect(all1[0].data.source).toBe(link.data.source)
expect(all1[0].data.predicate).toBe(link.data.predicate)
expect(all1[0].data.target).toBe(link.data.target)
});
})
Then your can run the test like so:
ad4m-test --test ./expression.test.js --bundle languages/sdp.js --meta '{\"name\":\"shortform-expression\",\"description\":\"Shortform expression for flux application\",\"sourceCodeLink\":\"https://github.com/juntofoundation/ad4m-languages\",\"possibleTemplateParams\":[\"uid\",\"name\"]}'
Running the below command will start a local server which will host the ExpressionUI which can be used to test UI for the expression language.
ad4m-test --ui --bundle languages/sdp.js --meta '{\"name\":\"shortform-expression\",\"description\":\"Shortform expression for flux application\",\"sourceCodeLink\":\"https://github.com/juntofoundation/ad4m-languages\",\"possibleTemplateParams\":[\"uid\",\"name\"]}'
Cli params:
relativePath | rp
- Relative path to the appdata for ad4m-host to store binariestest | t
- Runs test on a single filebundle | b
- Language bundle for the language to be testedmeta | m
- Meta information for the language to be installeddefaultLangPath | dlp
- Local bulid-in language to be used instead of the packaged oneshideLogs | hl
- Hide the ad4m-test logsui
- Starts a local server with expressionUI loaded for testing.Helpers:
spawnExpressionAgent()
- Spawns a agent that can work with expressions.spawnLinkAgent()
- Spawns an agent that can work with link and multiple agents are part of same neighbourhood to similify testing.FAQs
Testing library to test ad4m languages
The npm package @coasys/ad4m-test receives a total of 1 weekly downloads. As such, @coasys/ad4m-test popularity was classified as not popular.
We found that @coasys/ad4m-test demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.