Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ballerina/client.bal
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public isolated client class Client {
# + config - The configurations to be used when initializing the `connector`
# + serviceUrl - URL of the target service
# + return - An error if connector initialization failed
public isolated function init(ConnectionConfig config, string serviceUrl = "https://api.dfgdfghubapi.com/crm-object-schemas/v3/schemas") returns error? {
public isolated function init(ConnectionConfig config, string serviceUrl = "https://api.hubapi.com/crm-object-schemas/v3/schemas") returns error? {
http:ClientConfiguration httpClientConfig = {httpVersion: config.httpVersion, timeout: config.timeout, forwarded: config.forwarded, poolConfig: config.poolConfig, compression: config.compression, circuitBreaker: config.circuitBreaker, retryConfig: config.retryConfig, validation: config.validation};
do {
if config.http1Settings is ClientHttp1Settings {
Expand Down
15 changes: 0 additions & 15 deletions ballerina/tests/mock_service.bal
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

import ballerina/http;


listener http:Listener httpListener = new (3000);

http:Service mockService = service object {

resource function post token() returns json {
Expand Down Expand Up @@ -319,15 +316,3 @@ http:Service mockService = service object {

};

function init() returns error? {
// if isLiveServer {
// log:printInfo("Skiping mock server initialization as the tests are running on live server");
// return;
// }


check httpListener.attach(mockService, "/");
check httpListener.'start();
}


22 changes: 16 additions & 6 deletions ballerina/tests/tests.bal
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@
// under the License.

import ballerina/http;
import ballerina/io;
import ballerina/oauth2;
import ballerina/test;
import ballerina/io;

configurable boolean isLive = false;
configurable string clientId = "testClientId";
configurable string clientSecret = "testClientSecret";
configurable string refreshToken = "testRefreshToken";

string serviceUrl = isLive ? "" : "http://127.0.0.1:3000";

string serviceUrl = isLive ? "https://api.hubapi.com/crm-object-schemas/v3/schemas" : "http://127.0.0.1:3000";

OAuth2RefreshTokenGrantConfig auth = {
clientId,
Expand All @@ -42,11 +41,23 @@ ConnectionConfig config = {
auth: auth
};


listener http:Listener httpListener = new (3000);

// HubSpot CRM Client for interacting with HubSpot's Object Schemas API
final Client hpClient = check new Client(config, serviceUrl);
final Client hpClient;

function init() returns error? {
if isLive {
io:println("Skipping mock server initialization as the tests are running on live server");

} else {
io:println("Initiating mock server");
check httpListener.attach(mockService, "/");
check httpListener.'start();
}

hpClient = check new Client(config, serviceUrl);
}

@test:Config {
groups: ["live_tests", "mock_tests"]
Expand Down Expand Up @@ -130,7 +141,6 @@ isolated function testPatchSchema() returns error? {
// Make PATCH request to update the schema
ObjectTypeDefinition response = check hpClient->/[objId].patch(payload);
test:assertNotEquals(response.updatedAt, ());

}

// Test: Create Schema - Creates a new assosiation
Expand Down
Loading