Skip to content

Commit

Permalink
Update mock_service and test bal files with by removing unnecessory c…
Browse files Browse the repository at this point in the history
…omments and empty lines
  • Loading branch information
vish-mv committed Jul 2, 2024
1 parent aa67883 commit aa484ff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
9 changes: 1 addition & 8 deletions ballerina/tests/mock_service.bal
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ http:Service mockService = service object {
return response;
}



# Causes the User (in the path) to unlike the specified Post
#
# + id - The ID of the authenticated source User that is requesting to unlike the Post.
Expand Down Expand Up @@ -121,7 +119,6 @@ http:Service mockService = service object {
return response;
}


# Creation of a Post
#
# + return - returns can be any of following types
Expand All @@ -134,7 +131,6 @@ http:Service mockService = service object {
return response;
}


# Add Post to Bookmarks
#
# + id - The ID of the authenticated source User for whom to add bookmarks.
Expand All @@ -148,7 +144,6 @@ http:Service mockService = service object {
return response;
}


# Follow User
#
# + id - The ID of the authenticated source User that is requesting to follow the target User.
Expand Down Expand Up @@ -188,7 +183,6 @@ http:Service mockService = service object {
return response;
}


# Causes the User (in the path) to repost the specified Post.
#
# + id - The ID of the authenticated source User that is requesting to repost the Post.
Expand Down Expand Up @@ -227,5 +221,4 @@ function init() returns error? {
log:printInfo("Initiating mock server");
check httpListener.attach(mockService, "/");
check httpListener.'start();
}

}
19 changes: 2 additions & 17 deletions ballerina/tests/test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ import ballerina/os;
configurable boolean isLiveServer = os:getEnv("IS_LIVE_SERVER") == "true";
configurable string userId = isLiveServer ? os:getEnv("TWITTER_USER_ID") : "test";
configurable string token = isLiveServer ? os:getEnv("TWITTER_TOKEN") : "test";
configurable string serviceUrl = isLiveServer ? "https://api.twitter.com/2" : "http://localhost:9090/";
configurable string serviceUrl = isLiveServer ? "https://api.twitter.com/2" : "http://localhost:9090";

ConnectionConfig config = {auth: {token: token}};
final Client twitter = check new Client(config, serviceUrl);

//Test Posting a Tweet
@test:Config {
}
isolated function testPostTweet() returns error? {
Expand All @@ -39,7 +38,6 @@ isolated function testPostTweet() returns error? {
test:assertTrue(response?.errors is ());
}

//Test Get Twitter User Id of a user By Username
@test:Config {
}
isolated function testgetUserIdByUseName() returns error? {
Expand All @@ -48,7 +46,6 @@ isolated function testgetUserIdByUseName() returns error? {
test:assertTrue(response?.errors is ());
}

//Test Like a Post via Post ID
@test:Config {
}
isolated function testUserLikeAPost() returns error? {
Expand All @@ -61,7 +58,6 @@ isolated function testUserLikeAPost() returns error? {
test:assertTrue(response?.errors is ());
}

//Test Unlike a Post via Post ID
@test:Config {
}
isolated function testUserUnlikeAPost() returns error? {
Expand All @@ -70,7 +66,6 @@ isolated function testUserUnlikeAPost() returns error? {
test:assertTrue(response?.errors is ());
}

//Test grab information of a specific post via Id
@test:Config {
}
isolated function testPostLookup() returns error? {
Expand All @@ -79,7 +74,6 @@ isolated function testPostLookup() returns error? {
test:assertTrue(response?.errors is ());
}

//Test Bookmark a Post
@test:Config {
}
isolated function testBookmarkPost() returns error? {
Expand All @@ -90,7 +84,6 @@ isolated function testBookmarkPost() returns error? {
test:assertTrue(response?.errors is ());
}

//Test Unbookmark a Post
@test:Config {
}
isolated function testBookmarkDelete() returns error? {
Expand All @@ -99,8 +92,6 @@ isolated function testBookmarkDelete() returns error? {
test:assertTrue(response?.errors is ());
}


//Test Retweet a Post via Post ID
@test:Config {
}
isolated function testRetweet() returns error? {
Expand All @@ -111,7 +102,6 @@ isolated function testRetweet() returns error? {
test:assertTrue(response?.errors is ());
}

//Test Unretweet a Post via Post ID
@test:Config {
}
isolated function testDeleteRetweet() returns error? {
Expand All @@ -120,7 +110,6 @@ isolated function testDeleteRetweet() returns error? {
test:assertTrue(response?.errors is ());
}

//Test Follow a Specific User
@test:Config {
}
isolated function testFollowSpecificUser() returns error? {
Expand All @@ -133,7 +122,6 @@ isolated function testFollowSpecificUser() returns error? {
test:assertTrue(response?.errors is ());
}

//Test Unfollow a Specific User
@test:Config {
}
isolated function testUnfollowSpecificUser() returns error? {
Expand All @@ -142,7 +130,6 @@ isolated function testUnfollowSpecificUser() returns error? {
test:assertTrue(response?.errors is ());
}

//Test Mute a Specific User
@test:Config {
}
isolated function muteSpecificUser() returns error? {
Expand All @@ -155,7 +142,6 @@ isolated function muteSpecificUser() returns error? {
test:assertTrue(response?.errors is ());
}

//Test Unmute a Specific User
@test:Config {
}
isolated function unmuteSpecificUser() returns error? {
Expand All @@ -164,11 +150,10 @@ isolated function unmuteSpecificUser() returns error? {
test:assertTrue(response?.errors is ());
}

//Test FInd User Via ID
@test:Config {
}
isolated function findSpecificUser() returns error? {
Get2UsersResponse response = check twitter->/users(ids = ["1803011651249278976"]);
test:assertTrue(response?.data !is ());
test:assertTrue(response?.errors is ());
}
}

0 comments on commit aa484ff

Please sign in to comment.