Skip to content

Commit

Permalink
changed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pasindu599 committed Jan 17, 2025
1 parent 8e138e2 commit 3496e7b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions ballerina/tests/mock_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ final Client mockClient = check new (
final string mockFormId = "b6336282-50ec-465e-894e-e368146fa25f";

@test:Config {
groups: ["mock_tests"]
groups: ["mock_service_test"]
}
isolated function mockTestGetForm() returns error? {
CollectionResponseFormDefinitionBaseForwardPaging response = check mockClient->/.get();
test:assertTrue(response?.results.length() > 0);
}

@test:Config {
groups: ["mock_tests"]
groups: ["mock_service_test"]
}
isolated function mockTestGetFormById() returns error? {
FormDefinitionBase response = check mockClient->/[mockFormId].get();
Expand Down
24 changes: 13 additions & 11 deletions ballerina/tests/tests.bal
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,39 @@
// under the License.

import ballerina/oauth2;
import ballerina/os;
import ballerina/test;
import ballerina/time;

configurable string clientId = ?;
configurable string clientSecret = ?;
configurable string refreshToken = ?;
configurable boolean enableClient0auth2 = os:getEnv("IS_LIVE_SERVER") == "false";
configurable string clientId = enableClient0auth2 ? os:getEnv("CLIENT_ID") : "test";
configurable string clientSecret = enableClient0auth2 ? os:getEnv("CLIENT_SECRET") : "test";
configurable string refreshToken = enableClient0auth2 ? os:getEnv("REFRESH_TOKEN") : "test";

OAuth2RefreshTokenGrantConfig auth = {
clientId,
clientSecret,
refreshToken,
credentialBearer: oauth2:POST_BODY_BEARER // this line should be added to create auth object.
credentialBearer: oauth2:POST_BODY_BEARER

};

ConnectionConfig config = {auth: auth};
ConnectionConfig config = {auth: enableClient0auth2 ? auth : {token: "Bearer token"}};
final Client baseClient = check new Client(config);

final time:Utc currentUtc = time:utcNow();
string formId = "";

@test:Config {
groups: ["live_tests"]
groups: ["live_service_test"]
}
isolated function testGetForm() returns error? {
CollectionResponseFormDefinitionBaseForwardPaging response = check baseClient->/.get();
test:assertTrue(response?.results.length() > 0);
}

@test:Config {
groups: ["live_tests"]
groups: ["live_service_test"]
}
function testCreateForm() returns error? {
FormDefinitionBase response = check baseClient->/.post(
Expand Down Expand Up @@ -126,7 +128,7 @@ function testCreateForm() returns error? {

@test:Config {
dependsOn: [testCreateForm],
groups: ["live_tests"]
groups: ["live_service_test"]
}
function testGetFormById() returns error? {
FormDefinitionBase response = check baseClient->/[formId]();
Expand All @@ -136,7 +138,7 @@ function testGetFormById() returns error? {

@test:Config {
dependsOn: [testCreateForm],
groups: ["live_tests"]
groups: ["live_service_test"]
}
function testUpdateEntireForm() returns error? {
FormDefinitionBase response = check baseClient->/[formId].put(
Expand Down Expand Up @@ -217,7 +219,7 @@ function testUpdateEntireForm() returns error? {

@test:Config {
dependsOn: [testCreateForm],
groups: ["live_tests"]
groups: ["live_service_test"]
}
function testUpdateForm() returns error? {
FormDefinitionBase response = check baseClient->/[formId].patch(
Expand All @@ -230,7 +232,7 @@ function testUpdateForm() returns error? {

@test:Config {
dependsOn: [testCreateForm],
groups: ["live_tests"]
groups: ["live_service_test"]
}
function testDeleteForm() returns error? {
json response = check baseClient->/[formId].delete();
Expand Down

0 comments on commit 3496e7b

Please sign in to comment.