Skip to content

Commit

Permalink
chore: Update caveats about tests and requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
alexalexandrescu committed Dec 1, 2023
1 parent 53eec77 commit 556d950
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 54 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ jobs:
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
run: npm audit signatures

- name: Test
run: npm test

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
Expand Down
22 changes: 0 additions & 22 deletions .github/workflows/test.yml

This file was deleted.

13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Avro Tools CLI

## Description
Avro Tools CLI is a command-line interface for validating and converting Avro schemas. Built with Node.js and Yargs, it offers a basic yet opinionated way to manage Avro schema files.
Avro Tools CLI is a command-line interface for validating and converting [Avro schemas](https://avro.apache.org/docs/#schemas). Built with Node.js and Yargs, it offers a basic yet opinionated way to manage Avro schema files.

## Features
- Validate Avro schemas.
Expand Down Expand Up @@ -56,9 +56,14 @@ Create an avroConfig.json file:
}
```

## Development
Node.js Version: xx.xx
ESM Modules
## Requirements
- Node.js version 14 or higher is required for this tool, as it relies on ECMAScript Modules (ESM) which have stable support from version 14 onwards.

## Testing
The test suite for Avro Tools CLI is currently a work in progress. We use Jest for our testing framework, but please note that Jest's support for ECMAScript Modules (ESM) is still experimental. As a result, some tests may not yet achieve full coverage or may exhibit unexpected behavior. We are actively working to improve the test suite as the tooling evolves.
For the latest information on Jest's ESM support, see their [official documentation](https://jestjs.io/docs/ecmascript-modules).


## Local Setup
```bash
Expand Down
23 changes: 23 additions & 0 deletions __tests__/loadConfig.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// loadConfig.test.js
import { loadConfig } from './loadConfig';
import fs from 'fs';
import path from 'path';

jest.mock('fs');
jest.mock('path');

describe('loadConfig', () => {
beforeEach(() => {
jest.clearAllMocks();
});

it('loads and parses a valid config file', () => {
fs.readFileSync.mockReturnValue(JSON.stringify({ include: ['test'] }));
path.resolve.mockReturnValue('path/to/config.json');

const config = loadConfig('config.json');
expect(config).toEqual({ include: ['test'] });
});

// More tests for error handling...
});
19 changes: 19 additions & 0 deletions __tests__/main.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// main.test.js
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import main from './main';

jest.mock('yargs');
jest.mock('hideBin');

describe('main CLI', () => {
it('registers commands and options', () => {
// Call main and inspect yargs configuration
main();
expect(yargs.command).toHaveBeenCalled();
expect(yargs.option).toHaveBeenCalled();
// Add more expectations based on your yargs setup
});

// More tests for CLI behavior...
});
25 changes: 25 additions & 0 deletions __tests__/validate.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// validate.test.js
import validate, { readSchemaFile, isSchemaValid } from '../commands/validate';
import avro from 'avsc';
import fs from 'fs';
import { glob } from 'glob';
import chalk from 'chalk';

jest.mock('fs');
jest.mock('avsc');
jest.mock('glob');

describe('validate command', () => {
beforeEach(() => {
jest.clearAllMocks();
});

it('readSchemaFile reads and returns schema file content', () => {
fs.readFileSync.mockReturnValue('{"type": "record"}');
const content = readSchemaFile('path/to/schema.avsc');
expect(content).toBe('{"type": "record"}');
expect(fs.readFileSync).toHaveBeenCalledWith('path/to/schema.avsc', 'utf8');
});

// More tests for isSchemaValid and the command handler...
});
25 changes: 0 additions & 25 deletions __tests__/validateSchema.test.js

This file was deleted.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"**/?(*.)+(spec|test).[tj]s?(x)"
]
},
"engines": {
"node": ">=14"
},
"release": {
"branches": [
{
Expand Down

0 comments on commit 556d950

Please sign in to comment.