Skip to content

Commit

Permalink
Merge pull request #5 from ballerina-platform/Fix-tests
Browse files Browse the repository at this point in the history
Add default values to test configurables
  • Loading branch information
ThisaruGuruge authored Jan 10, 2025
2 parents d4c98db + 2037c70 commit 5e2f2ad
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions ballerina/tests/test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@

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

configurable string clientId = ?;
configurable string clientSecret = ?;
configurable string refreshToken = ?;
final string clientId = os:getEnv("HUBSPOT_CLIENT_ID");
final string clientSecret = os:getEnv("HUBSPOT_CLIENT_SECRET");
final string refreshToken = os:getEnv("HUBSPOT_REFRESH_TOKEN");

// isLiveSever is set to false by default, set to true in Config.toml
configurable boolean isLiveServer = false;
Expand All @@ -34,7 +35,24 @@ OAuth2RefreshTokenGrantConfig auth = {
credentialBearer: oauth2:POST_BODY_BEARER // this line should be added to create auth object.
};

final Client hubspotClient = check new ({auth}, serviceUrl);
final Client hubspotClient = check initClient();

isolated function initClient() returns Client|error {
if isLiveServer {
OAuth2RefreshTokenGrantConfig auth = {
clientId: clientId,
clientSecret: clientSecret,
refreshToken: refreshToken,
credentialBearer: oauth2:POST_BODY_BEARER
};
return check new ({auth}, serviceUrl);
}
return check new ({
auth: {
token: "test-token"
}
}, serviceUrl);
}

// Change this value and test
final int days = 40;
Expand Down

0 comments on commit 5e2f2ad

Please sign in to comment.