Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
atuchin-m committed Nov 2, 2024
1 parent c7953bd commit a6253c5
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/seed_tools/commands/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,42 @@ describe('create command', () => {
);
});

describe('perf seeds', () => {
const validSeedsDir = path.join(testDataDir, 'perf_seeds');
const runTest = async (testCase: string, revision?: string) => {
const testCaseDir = path.join(validSeedsDir, testCase);
const studiesDir = path.join(testCaseDir, 'studies');
const outputFile = path.join(tempDir, 'output.bin');

const args = [
'node',
'create',
studiesDir,
outputFile,
'--perf_mode',
'--mock_serial_number',
'1',
];
args.push(...(revision ? ['--revision', revision] : []));
await create().parseAsync(args);

const output = await fs.readFile(outputFile);
const expectedOutput = await fs.readFile(
path.join(testCaseDir, 'expected_seed.bin'),
);
expect(output).toEqual(expectedOutput);

expect(VariationsSeed.fromBinary(output).version).toEqual('1');
};

fs_sync.readdirSync(validSeedsDir).forEach((testCase) => {
it(testCase, () => runTest(testCase, undefined));

// Check creating seed using git history.
it(`${testCase}_old_revision`, () => runTest(testCase, 'HEAD'));
});
});

test('set seed version', async () => {
const testCaseDir = path.join(testDataDir, 'set_seed_version');
const studiesDir = path.join(testCaseDir, 'studies');
Expand Down

0 comments on commit a6253c5

Please sign in to comment.