Skip to content

Commit

Permalink
Merge pull request #11 from kapilraajP/slalpha5
Browse files Browse the repository at this point in the history
Fix build issues by moving delete operation tests to Aftersuite and add document comments
  • Loading branch information
abeykoon authored May 31, 2021
2 parents 58ee23e + dc6263c commit ae64f56
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 30 deletions.
2 changes: 1 addition & 1 deletion endpoint.bal
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public type GoogleContactsConfiguration record {
# Google Contacts Client.
#
# + googleContactClient - The HTTP Client
@display {label: "Google People API Client", iconPath: "GooglePeopleLogo.png"}
@display {label: "Google People API", iconPath: "GooglePeopleLogo.png"}
public client class Client {
public http:Client googleContactClient;

Expand Down
57 changes: 28 additions & 29 deletions tests/main_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,7 @@ function testUpdateContact() {
}
}

@test:Config {dependsOn: [testCreateContact, testGetContact, testUpdateContact]}
function testDeleteContact() {
log:printInfo("Running Delete Contact Test");
runtime:sleep(10);
var deleteContact = googleContactClient->deleteContact(contactResourceName);
if (deleteContact is ()) {
test:assertTrue(true, msg = "Delete Contact Failed");
} else {
test:assertFail(msg = deleteContact.message());
}
}

@test:Config {dependsOn: [testDeleteContact]}
@test:Config {dependsOn: [testUpdateContact]}
function testGetContactGroup() {
log:printInfo("Running Get Contact Group Test");
runtime:sleep(10);
Expand Down Expand Up @@ -291,25 +279,36 @@ function testUpdateContactGroup() {
}
}

@test:Config {dependsOn: [testUpdateContactGroup]}
function testDeleteContactGroup() {
log:printInfo("Running Delete Contact Group Test");
var deleteContactGroup = googleContactClient->deleteContactGroup(contactGroupResourceName);
if (deleteContactGroup is ()) {
test:assertTrue(true, msg = "Delete Contact Group Failed");
} else {
test:assertFail(msg = deleteContactGroup.message());
}
}

@test:AfterSuite { }
function afterSuite() {
log:printInfo("AfterSuite");
runtime:sleep(10);
var deleteContact = googleContactClient->deleteContact(beforeSuiteResourceName);
if (deleteContact is ()) {
test:assertTrue(true, msg = "Delete Contact Failed");
} else {
test:assertFail(msg = deleteContact.message());
if (beforeSuiteResourceName != "") {
var deleteContact = googleContactClient->deleteContact(beforeSuiteResourceName);
if (deleteContact is error) {
log:printError("Delete Contact Failed for resource name=" + beforeSuiteResourceName);
} else {
log:printInfo("Contact deleted sucessfully");
}
runtime:sleep(10);
}

if (contactResourceName != "") {
var deleteContact = googleContactClient->deleteContact(contactResourceName);
if (deleteContact is error) {
log:printError("Delete Contact Failed for resource name=" + contactResourceName);
} else {
log:printInfo("Contact deleted sucessfully");
}
runtime:sleep(10);
}

if (contactGroupResourceName != "") {
var deleteContactGroup = googleContactClient->deleteContactGroup(contactGroupResourceName);
if (deleteContactGroup is error) {
log:printError("Delete Contact group Failed for resource name" + contactGroupResourceName);
} else {
log:printInfo("Contact group deleted sucessfully");
}
}
}

0 comments on commit ae64f56

Please sign in to comment.