Skip to content

Commit

Permalink
Merge pull request #105 from ballerina-platform/parallel-test
Browse files Browse the repository at this point in the history
Make test functions isolated
  • Loading branch information
TharmiganK authored Sep 12, 2024
2 parents e4f6f0a + c9937a6 commit 09fdb97
Show file tree
Hide file tree
Showing 15 changed files with 170 additions and 171 deletions.
6 changes: 3 additions & 3 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org = "ballerina"
name = "constraint"
version = "1.5.0"
version = "1.5.1"
authors = ["Ballerina"]
keywords = ["constraint", "validation"]
repository = "https://github.com/ballerina-platform/module-ballerina-constraint"
Expand All @@ -15,5 +15,5 @@ graalvmCompatible = true
[[platform.java17.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "constraint-native"
version = "1.5.0"
path = "../native/build/libs/constraint-native-1.5.0.jar"
version = "1.5.1"
path = "../native/build/libs/constraint-native-1.5.1-SNAPSHOT.jar"
2 changes: 1 addition & 1 deletion ballerina/CompilerPlugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ id = "constraint-compiler-plugin"
class = "io.ballerina.stdlib.constraint.compiler.ConstraintCompilerPlugin"

[[dependency]]
path = "../compiler-plugin/build/libs/constraint-compiler-plugin-1.5.0.jar"
path = "../compiler-plugin/build/libs/constraint-compiler-plugin-1.5.1-SNAPSHOT.jar"
2 changes: 1 addition & 1 deletion ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ distribution-version = "2201.8.0"
[[package]]
org = "ballerina"
name = "constraint"
version = "1.5.0"
version = "1.5.1"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "test"},
Expand Down
26 changes: 13 additions & 13 deletions ballerina/tests/advanced_constraint_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ int b = 0;
type StringA string;

@test:Config {}
function testInvalidLengthConstraintOnStringType() {
isolated function testInvalidLengthConstraintOnStringType() {
StringA stringA = "s3cr3t";
StringA|error validation = validate(stringA);
if validation is error {
Expand All @@ -562,7 +562,7 @@ type RecordB record {
};

@test:Config {}
function testInvalidLengthConstraintOnStringTypeAsRecordField() {
isolated function testInvalidLengthConstraintOnStringTypeAsRecordField() {
RecordB recordB = {stringB: "s3cr3t"};
RecordB|error validation = validate(recordB);
if validation is error {
Expand All @@ -580,7 +580,7 @@ type RecordA record {
};

@test:Config {}
function testInvalidLengthConstraintOnArrayRecordField() {
isolated function testInvalidLengthConstraintOnArrayRecordField() {
RecordA recordA = {arrayA: ["s3cr3t"]};
RecordA|error validation = validate(recordA);
if validation is error {
Expand Down Expand Up @@ -689,7 +689,7 @@ type OrderNew record {|
|};

@test:Config {}
function testCustomAnnotationSuccess() {
isolated function testCustomAnnotationSuccess() {
OrderNew rec = {
id: "1000",
productId: "23",
Expand All @@ -703,7 +703,7 @@ function testCustomAnnotationSuccess() {
}

@test:Config {}
function testCustomAnnotationFailure() {
isolated function testCustomAnnotationFailure() {
OrderNew rec = {
id: "1000",
productId: "23",
Expand Down Expand Up @@ -736,23 +736,23 @@ type NickName Name;
type Id int:Signed32;

@test:Config {}
function testConstraintAnnotationOnSubtypeSuccess1() {
isolated function testConstraintAnnotationOnSubtypeSuccess1() {
NickName|error validation = validate("J");
if validation is error {
test:assertFail("Unexpected error found.");
}
}

@test:Config {}
function testConstraintAnnotationOnSubtypeSuccess2() {
isolated function testConstraintAnnotationOnSubtypeSuccess2() {
Id|error validation = validate(100);
if validation is error {
test:assertFail("Unexpected error found.");
}
}

@test:Config {}
function testConstraintAnnotationOnSubtypeFailure1() {
isolated function testConstraintAnnotationOnSubtypeFailure1() {
NickName|error validation = validate("James Maccurdy");
if validation is error {
test:assertEquals(validation.message(), "Validation failed for '$:maxLength' constraint(s).");
Expand All @@ -762,7 +762,7 @@ function testConstraintAnnotationOnSubtypeFailure1() {
}

@test:Config {}
function testConstraintAnnotationOnSubtypeFailure2() {
isolated function testConstraintAnnotationOnSubtypeFailure2() {
Id|error validation = validate(1001);
if validation is error {
test:assertEquals(validation.message(), "Validation failed for '$:maxValue' constraint(s).");
Expand Down Expand Up @@ -793,7 +793,7 @@ type UserNew record {
};

@test:Config {}
function testConstraintAnnotationOnSubtypeAsRecordFieldSuccess() {
isolated function testConstraintAnnotationOnSubtypeAsRecordFieldSuccess() {
UserNew user = {
id: 1,
name: {
Expand All @@ -810,7 +810,7 @@ function testConstraintAnnotationOnSubtypeAsRecordFieldSuccess() {
}

@test:Config {}
function testConstraintAnnotationOnSubtypeAsRecordFieldFailure() {
isolated function testConstraintAnnotationOnSubtypeAsRecordFieldFailure() {
UserNew user = {
id: 1,
name: {
Expand All @@ -836,7 +836,7 @@ type UserDetails record {|
|};

@test:Config {}
function testConstraintOnFieldsWithEscapeCharsSuccess() {
isolated function testConstraintOnFieldsWithEscapeCharsSuccess() {
UserDetails user = {
x\-name: "John Doe",
x\-age\$: [18, 19]
Expand All @@ -848,7 +848,7 @@ function testConstraintOnFieldsWithEscapeCharsSuccess() {
}

@test:Config {}
function testConstraintOnFieldsWithEscapeCharsFailure() {
isolated function testConstraintOnFieldsWithEscapeCharsFailure() {
UserDetails user = {
x\-name: "J",
x\-age\$: [17, 19, 20, 15]
Expand Down
12 changes: 6 additions & 6 deletions ballerina/tests/constraint_on_array_members_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type App2 record {|
type Users User[];

@test:Config {}
function testConstraintsOnArrayBasicMembersSuccess() {
isolated function testConstraintsOnArrayBasicMembersSuccess() {
UserId[] ids = ["1234", "4356", "9834", "3214"];
do {
ids = check validate(ids);
Expand All @@ -49,7 +49,7 @@ function testConstraintsOnArrayBasicMembersSuccess() {
}

@test:Config {}
function testConstraintsOnArrayBasicMembersFailure() {
isolated function testConstraintsOnArrayBasicMembersFailure() {
UserId[] ids = ["1234", "43", "9834", "3214"];
do {
ids = check validate(ids);
Expand All @@ -74,7 +74,7 @@ function testConstraintsOnArrayBasicMembersFailure() {
}

@test:Config {}
function testConstraintsOnRecordFieldArrayMembersSuccess() {
isolated function testConstraintsOnRecordFieldArrayMembersSuccess() {
UserId[] ids = ["1234", "4356", "9834", "3214"];

App1|error validation1 = validate({ids: ids});
Expand All @@ -89,7 +89,7 @@ function testConstraintsOnRecordFieldArrayMembersSuccess() {
}

@test:Config {}
function testConstraintsOnRecordFieldArrayMembersFailure() {
isolated function testConstraintsOnRecordFieldArrayMembersFailure() {
UserId[] ids = ["1234", "43", "9834", "3214"];

App1|error validation1 = validate({ids: ids});
Expand All @@ -108,7 +108,7 @@ function testConstraintsOnRecordFieldArrayMembersFailure() {
}

@test:Config {}
function testConstraintsOnRecordArrayMemberSuccess() {
isolated function testConstraintsOnRecordArrayMemberSuccess() {
User[] users = [
{id: 1, name: "John"},
{id: 2, name: "Joyce"}
Expand All @@ -127,7 +127,7 @@ function testConstraintsOnRecordArrayMemberSuccess() {
}

@test:Config {}
function testConstraintsOnRecordArrayMemberFailure() {
isolated function testConstraintsOnRecordArrayMemberFailure() {
User[] users = [
{id: 1, name: "John"},
{id: 2, name: "a"}
Expand Down
28 changes: 14 additions & 14 deletions ballerina/tests/constraint_on_readonly_type_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type ReadOnlyAlbumWithoutConstraints readonly & record {|
|};

@test:Config {}
function testReadOnlyAlbumWithoutConstraints() {
isolated function testReadOnlyAlbumWithoutConstraints() {
Album album = {title: "Blue Train", artist: "John Coltrane"};
ReadOnlyAlbum|error validation1 = validate(album);
if validation1 is error {
Expand Down Expand Up @@ -75,7 +75,7 @@ type ReadOnlyAlbumWithConstraints readonly & record {|
|};

@test:Config {}
function testReadOnlyAlbumWithConstraintsSuccess() {
isolated function testReadOnlyAlbumWithConstraintsSuccess() {
Album album = {title: "Jeru", artist: "Gerry Mulligan"};
ReadOnlyConstrainedAlbum|error validation1 = validate(album);
if validation1 is error {
Expand All @@ -101,7 +101,7 @@ function testReadOnlyAlbumWithConstraintsSuccess() {
}

@test:Config {}
function testReadOnlyAlbumWithConstraintsFailure() {
isolated function testReadOnlyAlbumWithConstraintsFailure() {
Album album = {title: "Blue Train", artist: "John Coltrane"};
ReadOnlyConstrainedAlbum|error validation1 = validate(album);
if validation1 is error {
Expand Down Expand Up @@ -143,7 +143,7 @@ type AlbumWithReadOnlyConstraints record {|
|};

@test:Config {}
function testAlbumWithReadOnlyConstraintsSuccess() {
isolated function testAlbumWithReadOnlyConstraintsSuccess() {
Album album = {title: "Jeru", artist: "Gerry Mulligan"};
AlbumWithReadOnlyConstraints|error validation = validate(album);
if validation is error {
Expand All @@ -152,7 +152,7 @@ function testAlbumWithReadOnlyConstraintsSuccess() {
}

@test:Config {}
function testAlbumWithReadOnlyConstraintsFailure() {
isolated function testAlbumWithReadOnlyConstraintsFailure() {
Album album = {title: "Blue Train", artist: "John Coltrane"};
AlbumWithReadOnlyConstraints|error validation = validate(album);
if validation is error {
Expand All @@ -174,7 +174,7 @@ type ReadOnlyAlbumWithConstraintType readonly & record {|
|};

@test:Config {}
function testReadOnlyAlbumWithConstraintTypeSuccess() {
isolated function testReadOnlyAlbumWithConstraintTypeSuccess() {
Album album = {title: "Jeru", artist: "Gerry Mulligan"};
ReadOnlyAlbumWithConstraintType|error validation = validate(album);
if validation is error {
Expand All @@ -183,7 +183,7 @@ function testReadOnlyAlbumWithConstraintTypeSuccess() {
}

@test:Config {}
function testReadOnlyAlbumWithConstraintTypeFailure() {
isolated function testReadOnlyAlbumWithConstraintTypeFailure() {
Album album = {title: "Blue Train", artist: "John Coltrane"};
ReadOnlyAlbumWithConstraintType|error validation = validate(album);
if validation is error {
Expand All @@ -205,7 +205,7 @@ type AlbumWithReadOnlyConstraintType record {|
|};

@test:Config {}
function testAlbumWithReadOnlyConstraintTypeSuccess() {
isolated function testAlbumWithReadOnlyConstraintTypeSuccess() {
Album album = {title: "Jeru", artist: "Gerry Mulligan"};
AlbumWithReadOnlyConstraintType|error validation = validate(album);
if validation is error {
Expand All @@ -214,7 +214,7 @@ function testAlbumWithReadOnlyConstraintTypeSuccess() {
}

@test:Config {}
function testAlbumWithReadOnlyConstraintTypeFailure() {
isolated function testAlbumWithReadOnlyConstraintTypeFailure() {
Album album = {title: "Blue Train", artist: "John Coltrane"};
AlbumWithReadOnlyConstraintType|error validation = validate(album);
if validation is error {
Expand All @@ -237,7 +237,7 @@ type Artist record {|
|};

@test:Config {}
function testArtistSuccess() {
isolated function testArtistSuccess() {
Artist artist = {
name: "Gerry Mulligan",
rating: 4,
Expand All @@ -253,7 +253,7 @@ function testArtistSuccess() {
}

@test:Config {}
function testArtistFailure() {
isolated function testArtistFailure() {
Artist artist = {
name: "John Coltrane",
rating: 4,
Expand All @@ -273,7 +273,7 @@ function testArtistFailure() {
type ReadOnlyArtist readonly & Artist;

@test:Config {}
function testReadOnlyArtistSuccess() {
isolated function testReadOnlyArtistSuccess() {
Artist artist = {
name: "Gerry Mulligan",
rating: 4,
Expand Down Expand Up @@ -301,7 +301,7 @@ function testReadOnlyArtistSuccess() {
}

@test:Config {}
function testReadOnlyArtistFailure1() {
isolated function testReadOnlyArtistFailure1() {
Artist artist = {
name: "Gerry Mulligan",
rating: 10,
Expand Down Expand Up @@ -334,7 +334,7 @@ function testReadOnlyArtistFailure1() {
}

@test:Config {}
function testReadOnlyArtistFailure2() {
isolated function testReadOnlyArtistFailure2() {
Artist artist = {
name: "John Coltrane",
rating: 10,
Expand Down
12 changes: 6 additions & 6 deletions ballerina/tests/constraint_validation_return_type_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type User record {|
|};

@test:Config {}
function testValidationWithCloneWithTypeSuccess1() {
isolated function testValidationWithCloneWithTypeSuccess1() {
json rec = {"id": 1, "name": "Joy"};
User|error validation = validate(rec);
if validation is error {
Expand All @@ -38,7 +38,7 @@ function testValidationWithCloneWithTypeSuccess1() {
}

@test:Config {}
function testValidationWithCloneWithTypeSuccess2() {
isolated function testValidationWithCloneWithTypeSuccess2() {
json rec = {"id": 1, "name": "Joy"};
do {
User validation = check validate(rec);
Expand All @@ -51,7 +51,7 @@ function testValidationWithCloneWithTypeSuccess2() {
}

@test:Config {}
function testValidationWithCloneWithTypeFailure1() {
isolated function testValidationWithCloneWithTypeFailure1() {
json rec = {"id": 1, "username": "Joy"};
User|error validation = validate(rec);
if validation is error {
Expand All @@ -62,7 +62,7 @@ function testValidationWithCloneWithTypeFailure1() {
}

@test:Config {}
function testValidationWithCloneWithTypeFailure2() {
isolated function testValidationWithCloneWithTypeFailure2() {
json rec = {"id": 1, "username": "Joy"};
do {
User _ = check validate(rec);
Expand All @@ -73,7 +73,7 @@ function testValidationWithCloneWithTypeFailure2() {
}

@test:Config {}
function testValidationWithoutCloneSuccess1() {
isolated function testValidationWithoutCloneSuccess1() {
User rec = {"id": 1, "name": "Joy"};
User|error validation = validate(rec);
if validation is error {
Expand All @@ -86,7 +86,7 @@ function testValidationWithoutCloneSuccess1() {
}

@test:Config {}
function testValidationWithoutCloneSuccess2() {
isolated function testValidationWithoutCloneSuccess2() {
User rec = {"id": 1, "name": "Joy"};
do {
User validation = check validate(rec);
Expand Down
Loading

0 comments on commit 09fdb97

Please sign in to comment.