Skip to content

Commit

Permalink
feat(cli): make concurrency optional
Browse files Browse the repository at this point in the history
  • Loading branch information
tstelzer committed May 14, 2024
1 parent 337e55d commit 8d17235
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
14 changes: 5 additions & 9 deletions workspace/examples/src/with-cli/simple.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import type * as PT from '@creative-introvert/tons-of-tests';
import * as CLI from '@creative-introvert/tons-of-tests-cli';
import {Effect} from 'effect';

void CLI.run({
testSuite: {
name: 'with-cli-simple',
testCases: [
{input: {BRAND: '1'}, expected: {BRAND: '1'}},
{input: null, expected: {BRAND: '2'}},
{input: {BRAND: '3', MODEL: 8100}, expected: null},
{input: null, expected: null},
{input: 1, expected: 1.1},
{input: 2, expected: 2.2},
{input: 3, expected: 3.3},
],
// eslint-disable-next-line @typescript-eslint/no-explicit-any
program: (args: any) =>
Effect.sync(() => args && {MODEL: args?.MODEL, BRAND: args?.BRAND}),
program: n =>
Effect.sync(() => Number.parseFloat((n * 1.1).toFixed(1))),
},
dbPath: 'with-cli-simple.db',
concurrency: 2,
});
2 changes: 1 addition & 1 deletion workspace/tons-of-tests-cli/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type Config<I = unknown, O = unknown, T = unknown> = {
testSuite: PT.Test.TestSuite<I, O, T>;
dbPath: string;
displayConfig?: Partial<PT.DisplayConfig.DisplayConfig> | undefined;
concurrency: number | undefined;
concurrency?: number | undefined;
};

export const Config = P.Context.GenericTag<Config>('Config');
Expand Down
4 changes: 2 additions & 2 deletions workspace/tons-of-tests-cli/src/summarize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ export const _sumarize = <I = unknown, O = unknown, T = unknown>({
concurrency: concurrency || 1,
}).pipe(
P.Effect.flatMap(PT.Test.runCollectRecord(currentTestRun)),
P.Effect.tap(P.Effect.log('from run')),
P.Effect.tap(P.Effect.logDebug('from run')),
);

const getFromCache = () =>
repository
.getTestResultsStream(currentTestRun)
.pipe(
PT.Test.runCollectRecord(currentTestRun),
P.Effect.tap(P.Effect.log('from cache')),
P.Effect.tap(P.Effect.logDebug('from cache')),
);

const testRun: PT.Test.TestRunResults = yield* P.Effect.if(
Expand Down

0 comments on commit 8d17235

Please sign in to comment.