Skip to content

Commit

Permalink
add short array constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Sep 11, 2024
1 parent f4b8954 commit cce56e7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
5 changes: 5 additions & 0 deletions test/property/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ export const defaultArrayConstraints = {
maxLength: 100
};

export const shortArrayConstraints = {
minLength: 5,
maxLength: 20
};

export function deepEqual(a: any, b: any): boolean {
const result = libraryDeepEqual(a, b);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { defaultArrayConstraints, runPropTests } from 'azle/test/property';
import {
defaultArrayConstraints,
runPropTests,
shortArrayConstraints
} from 'azle/test/property';
import { CandidReturnTypeArb } from 'azle/test/property/arbitraries/candid/candid_return_type_arb';
import { CandidValueAndMetaArb } from 'azle/test/property/arbitraries/candid/candid_value_and_meta_arb';
import {
Expand Down Expand Up @@ -32,7 +36,7 @@ const arrayConstraints =
process.env.AZLE_TEST_RUN_ON_RELEASE === 'true' ||
process.env.AZLE_TEST_RUN_ON_LOCAL === 'true'
? defaultArrayConstraints
: { ...defaultArrayConstraints, maxLength: 50 };
: shortArrayConstraints;

const CanisterConfigArb = fc
.array(HeterogeneousUpdateMethodArb, arrayConstraints)
Expand Down
8 changes: 6 additions & 2 deletions tests/property/candid_rpc/class_api/recursive/test/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { defaultArrayConstraints, runPropTests } from 'azle/test/property';
import {
defaultArrayConstraints,
runPropTests,
shortArrayConstraints
} from 'azle/test/property';
import { RecursiveArb } from 'azle/test/property/arbitraries/candid/recursive';
import {
CanisterArb,
Expand Down Expand Up @@ -46,7 +50,7 @@ const arrayConstraints =
process.env.AZLE_TEST_RUN_ON_RELEASE === 'true' ||
process.env.AZLE_TEST_RUN_ON_LOCAL === 'true'
? defaultArrayConstraints
: { ...defaultArrayConstraints, maxLength: 25 };
: shortArrayConstraints;

const CanisterConfigArb = fc
.array(AllRecursiveQueryMethodArb, arrayConstraints)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { defaultArrayConstraints, runPropTests } from 'azle/test/property';
import {
defaultArrayConstraints,
runPropTests,
shortArrayConstraints
} from 'azle/test/property';
import { CandidReturnTypeArb } from 'azle/test/property/arbitraries/candid/candid_return_type_arb';
import { CandidValueAndMetaArb } from 'azle/test/property/arbitraries/candid/candid_value_and_meta_arb';
import {
Expand Down Expand Up @@ -32,7 +36,7 @@ const arrayConstraints =
process.env.AZLE_TEST_RUN_ON_RELEASE === 'true' ||
process.env.AZLE_TEST_RUN_ON_LOCAL === 'true'
? defaultArrayConstraints
: { ...defaultArrayConstraints, maxLength: 50 };
: shortArrayConstraints;

const CanisterConfigArb = fc
.array(HeterogeneousUpdateMethodArb, arrayConstraints)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { defaultArrayConstraints, runPropTests } from 'azle/test/property';
import {
defaultArrayConstraints,
runPropTests,
shortArrayConstraints
} from 'azle/test/property';
import { RecursiveArb } from 'azle/test/property/arbitraries/candid/recursive';
import {
CanisterArb,
Expand Down Expand Up @@ -46,7 +50,7 @@ const arrayConstraints =
process.env.AZLE_TEST_RUN_ON_RELEASE === 'true' ||
process.env.AZLE_TEST_RUN_ON_LOCAL === 'true'
? defaultArrayConstraints
: { ...defaultArrayConstraints, maxLength: 25 };
: shortArrayConstraints;

const CanisterConfigArb = fc
.array(AllRecursiveQueryMethodArb, arrayConstraints)
Expand Down

0 comments on commit cce56e7

Please sign in to comment.