2024-01-24 06:51:43 +00:00
|
|
|
import { spawnSync } from 'child_process';
|
|
|
|
|
|
|
|
describe('Test laconic CLI commands', () => {
|
|
|
|
beforeAll(async () => {
|
|
|
|
// TODO: Install laconic binary (create symlink in path)
|
|
|
|
// TODO: Create a temp directory to run the tests in and cd into that
|
2024-01-24 07:17:38 +00:00
|
|
|
// TODO: Create the required config
|
2024-01-24 06:51:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
// TODO: Cleanup temp dir
|
|
|
|
});
|
|
|
|
|
|
|
|
test('laconic', async () => {
|
|
|
|
const result = spawnSync('laconic');
|
|
|
|
|
|
|
|
const output = result.stdout.toString().trim();
|
|
|
|
const errorOutput = result.stderr.toString().trim();
|
|
|
|
|
|
|
|
// Expect error with usage string
|
|
|
|
expect(output).toBe('');
|
|
|
|
expect(errorOutput).toContain('laconic <command>');
|
|
|
|
expect(result.status).toBe(1);
|
|
|
|
});
|
|
|
|
|
2024-01-24 07:17:38 +00:00
|
|
|
// TODO: Test subcommands
|
2024-01-24 06:51:43 +00:00
|
|
|
describe('laconic <command>', () => {
|
2024-01-24 07:17:38 +00:00
|
|
|
test('laconic cns', async () => {
|
|
|
|
const result = spawnSync('laconic', ['cns']);
|
|
|
|
|
|
|
|
const output = result.stdout.toString().trim();
|
|
|
|
const errorOutput = result.stderr.toString().trim();
|
|
|
|
|
|
|
|
// Expect error with usage string
|
|
|
|
expect(output).toBe('');
|
|
|
|
expect(errorOutput).toContain('laconic cns');
|
|
|
|
expect(errorOutput).toContain('CNS tools');
|
|
|
|
expect(errorOutput).toContain('Commands:');
|
|
|
|
expect(result.status).toBe(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('laconic cns <command>', () => {
|
|
|
|
test('laconic cns status', async () => {
|
|
|
|
const result = spawnSync('laconic', ['cns', 'status']);
|
|
|
|
|
|
|
|
const output = result.stdout.toString().trim();
|
|
|
|
const outputObj = JSON.parse(output);
|
|
|
|
const errorOutput = result.stderr.toString().trim();
|
|
|
|
|
|
|
|
// Expect output object to have CNS status props
|
|
|
|
expect(outputObj).toHaveProperty('version');
|
|
|
|
expect(outputObj).toHaveProperty('node');
|
|
|
|
expect(outputObj).toHaveProperty('node.network', 'laconic_9000-1');
|
|
|
|
expect(outputObj).toHaveProperty('sync');
|
|
|
|
expect(outputObj).toHaveProperty('validator');
|
|
|
|
expect(outputObj).toHaveProperty('validators');
|
|
|
|
expect(outputObj).toHaveProperty('num_peers');
|
|
|
|
expect(outputObj).toHaveProperty('peers');
|
|
|
|
expect(outputObj).toHaveProperty('disk_usage');
|
|
|
|
|
|
|
|
expect(errorOutput).toBe('');
|
|
|
|
expect(result.status).toBe(0);
|
|
|
|
});
|
|
|
|
});
|
2024-01-24 06:51:43 +00:00
|
|
|
});
|
|
|
|
});
|