From 1494f68dce7efbb92c5a7f34468aa2e15a547c8b Mon Sep 17 00:00:00 2001 From: Visal Munasinghe <127712545+vish-mv@users.noreply.github.com> Date: Thu, 4 Jul 2024 09:48:35 +0530 Subject: [PATCH 1/4] Update public user and post id use for test as final values --- ballerina/tests/test.bal | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/ballerina/tests/test.bal b/ballerina/tests/test.bal index 52a01d7..f6f8b4b 100644 --- a/ballerina/tests/test.bal +++ b/ballerina/tests/test.bal @@ -26,6 +26,9 @@ configurable string serviceUrl = isLiveServer ? "https://api.twitter.com/2" : "h ConnectionConfig config = {auth: {token}}; final Client twitter = check new Client(config, serviceUrl); +final string test_user_id = "15594932"; +final string test_post_id = "1808153657558311048"; + @test:Config { groups: ["live_tests", "mock_tests"] } @@ -54,7 +57,7 @@ isolated function testgetUserIdByUseName() returns error? { isolated function testUserLikeAPost() returns error? { UsersLikesCreateResponse response = check twitter->/users/[userId]/likes.post( payload = { - tweet_id:"1806286701704462623" + tweet_id:test_post_id } ); test:assertTrue(response?.data !is ()); @@ -65,7 +68,7 @@ isolated function testUserLikeAPost() returns error? { groups: ["live_tests", "mock_tests"] } isolated function testUserUnlikeAPost() returns error? { - UsersLikesDeleteResponse response = check twitter->/users/[userId]/likes/["1806286701704462623"].delete(); + UsersLikesDeleteResponse response = check twitter->/users/[userId]/likes/[test_post_id].delete(); test:assertTrue(response?.data !is ()); test:assertTrue(response?.errors is ()); } @@ -74,7 +77,7 @@ isolated function testUserUnlikeAPost() returns error? { groups: ["live_tests", "mock_tests"] } isolated function testPostLookup() returns error? { - Get2TweetsIdResponse response = check twitter->/tweets/["1806286701704462623"](); + Get2TweetsIdResponse response = check twitter->/tweets/[test_post_id](); test:assertTrue(response?.data !is ()); test:assertTrue(response?.errors is ()); } @@ -84,7 +87,7 @@ isolated function testPostLookup() returns error? { } isolated function testBookmarkPost() returns error? { BookmarkMutationResponse response = check twitter->/users/[userId]/bookmarks.post( - payload = {tweet_id: "1806286701704462623"} + payload = {tweet_id: test_post_id} ); test:assertTrue(response?.data !is ()); test:assertTrue(response?.errors is ()); @@ -94,7 +97,7 @@ isolated function testBookmarkPost() returns error? { groups: ["live_tests", "mock_tests"] } isolated function testBookmarkDelete() returns error? { - BookmarkMutationResponse response = check twitter->/users/[userId]/bookmarks/["1806286701704462623"].delete(); + BookmarkMutationResponse response = check twitter->/users/[userId]/bookmarks/[test_post_id].delete(); test:assertTrue(response?.data !is ()); test:assertTrue(response?.errors is ()); } @@ -104,7 +107,7 @@ isolated function testBookmarkDelete() returns error? { } isolated function testRetweet() returns error? { UsersRetweetsCreateResponse response = check twitter->/users/[userId]/retweets.post( - payload = {tweet_id: "1806286701704462623"} + payload = {tweet_id: test_post_id} ); test:assertTrue(response?.data !is ()); test:assertTrue(response?.errors is ()); @@ -114,7 +117,7 @@ isolated function testRetweet() returns error? { groups: ["live_tests", "mock_tests"] } isolated function testDeleteRetweet() returns error? { - UsersRetweetsDeleteResponse response = check twitter->/users/[userId]/retweets/["1806286701704462623"].delete(); + UsersRetweetsDeleteResponse response = check twitter->/users/[userId]/retweets/[test_post_id].delete(); test:assertTrue(response?.data !is ()); test:assertTrue(response?.errors is ()); } @@ -125,7 +128,7 @@ isolated function testDeleteRetweet() returns error? { isolated function testFollowSpecificUser() returns error? { UsersFollowingCreateResponse response = check twitter->/users/[userId]/following.post( payload={ - target_user_id:"1803011651249278976" + target_user_id:test_user_id } ); test:assertTrue(response?.data !is ()); @@ -136,7 +139,7 @@ isolated function testFollowSpecificUser() returns error? { groups: ["live_tests", "mock_tests"] } isolated function testUnfollowSpecificUser() returns error? { - UsersFollowingDeleteResponse response = check twitter->/users/[userId]/following/["1803011651249278976"].delete(); + UsersFollowingDeleteResponse response = check twitter->/users/[userId]/following/[test_user_id].delete(); test:assertTrue(response?.data !is ()); test:assertTrue(response?.errors is ()); } @@ -147,7 +150,7 @@ isolated function testUnfollowSpecificUser() returns error? { isolated function muteSpecificUser() returns error? { MuteUserMutationResponse response = check twitter->/users/[userId]/muting.post( payload={ - target_user_id:"1803011651249278976" + target_user_id:test_user_id } ); test:assertTrue(response?.data !is ()); @@ -159,7 +162,7 @@ isolated function muteSpecificUser() returns error? { } isolated function unmuteSpecificUser() returns error? { - MuteUserMutationResponse response = check twitter->/users/[userId]/muting/["1803011651249278976"].delete(); + MuteUserMutationResponse response = check twitter->/users/[userId]/muting/[test_user_id].delete(); test:assertTrue(response?.data !is ()); test:assertTrue(response?.errors is ()); } @@ -168,7 +171,7 @@ isolated function unmuteSpecificUser() returns error? { groups: ["live_tests", "mock_tests"] } isolated function findSpecificUser() returns error? { - Get2UsersResponse response = check twitter->/users(ids = ["1803011651249278976"]); + Get2UsersResponse response = check twitter->/users(ids = [test_user_id]); test:assertTrue(response?.data !is ()); test:assertTrue(response?.errors is ()); } \ No newline at end of file From afee124e789f8adb11eb0670e61b46ec8170c36e Mon Sep 17 00:00:00 2001 From: Nipuna Ranasinghe Date: Thu, 4 Jul 2024 10:00:51 +0530 Subject: [PATCH 2/4] Fix formatting --- ballerina/tests/tests.bal | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ballerina/tests/tests.bal b/ballerina/tests/tests.bal index f4dbae9..3f6390a 100644 --- a/ballerina/tests/tests.bal +++ b/ballerina/tests/tests.bal @@ -57,7 +57,7 @@ isolated function testgetUserIdByUseName() returns error? { isolated function testUserLikeAPost() returns error? { UsersLikesCreateResponse response = check twitter->/users/[userId]/likes.post( payload = { - tweet_id:test_post_id + tweet_id: test_post_id } ); test:assertTrue(response?.data !is ()); @@ -127,8 +127,8 @@ isolated function testDeleteRetweet() returns error? { } isolated function testFollowSpecificUser() returns error? { UsersFollowingCreateResponse response = check twitter->/users/[userId]/following.post( - payload={ - target_user_id:test_user_id + payload = { + target_user_id: test_user_id } ); test:assertTrue(response?.data !is ()); @@ -149,8 +149,8 @@ isolated function testUnfollowSpecificUser() returns error? { } isolated function muteSpecificUser() returns error? { MuteUserMutationResponse response = check twitter->/users/[userId]/muting.post( - payload={ - target_user_id:test_user_id + payload = { + target_user_id: test_user_id } ); test:assertTrue(response?.data !is ()); From 93b6f54bebb9f2f9af3e75d3ed48b3beed85a117 Mon Sep 17 00:00:00 2001 From: Visal Munasinghe <127712545+vish-mv@users.noreply.github.com> Date: Thu, 4 Jul 2024 10:13:26 +0530 Subject: [PATCH 3/4] Update Variable names in Test.bal Co-authored-by: Nipuna Ransinghe --- ballerina/tests/tests.bal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ballerina/tests/tests.bal b/ballerina/tests/tests.bal index 3f6390a..56e9519 100644 --- a/ballerina/tests/tests.bal +++ b/ballerina/tests/tests.bal @@ -26,8 +26,8 @@ configurable string serviceUrl = isLiveServer ? "https://api.twitter.com/2" : "h ConnectionConfig config = {auth: {token}}; final Client twitter = check new Client(config, serviceUrl); -final string test_user_id = "15594932"; -final string test_post_id = "1808153657558311048"; +final string testUserId = "15594932"; +final string testPostId = "1808153657558311048"; @test:Config { groups: ["live_tests", "mock_tests"] From 316577db3fbc75987ecf2058824ee3e5a579edd0 Mon Sep 17 00:00:00 2001 From: Visal Munasinghe <127712545+vish-mv@users.noreply.github.com> Date: Thu, 4 Jul 2024 10:17:34 +0530 Subject: [PATCH 4/4] Updated rest api parameteres according to new Variable names --- ballerina/tests/tests.bal | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ballerina/tests/tests.bal b/ballerina/tests/tests.bal index 56e9519..b28e4e6 100644 --- a/ballerina/tests/tests.bal +++ b/ballerina/tests/tests.bal @@ -57,7 +57,7 @@ isolated function testgetUserIdByUseName() returns error? { isolated function testUserLikeAPost() returns error? { UsersLikesCreateResponse response = check twitter->/users/[userId]/likes.post( payload = { - tweet_id: test_post_id + tweet_id: testPostId } ); test:assertTrue(response?.data !is ()); @@ -68,7 +68,7 @@ isolated function testUserLikeAPost() returns error? { groups: ["live_tests", "mock_tests"] } isolated function testUserUnlikeAPost() returns error? { - UsersLikesDeleteResponse response = check twitter->/users/[userId]/likes/[test_post_id].delete(); + UsersLikesDeleteResponse response = check twitter->/users/[userId]/likes/[testPostId].delete(); test:assertTrue(response?.data !is ()); test:assertTrue(response?.errors is ()); } @@ -77,7 +77,7 @@ isolated function testUserUnlikeAPost() returns error? { groups: ["live_tests", "mock_tests"] } isolated function testPostLookup() returns error? { - Get2TweetsIdResponse response = check twitter->/tweets/[test_post_id](); + Get2TweetsIdResponse response = check twitter->/tweets/[testPostId](); test:assertTrue(response?.data !is ()); test:assertTrue(response?.errors is ()); } @@ -87,7 +87,7 @@ isolated function testPostLookup() returns error? { } isolated function testBookmarkPost() returns error? { BookmarkMutationResponse response = check twitter->/users/[userId]/bookmarks.post( - payload = {tweet_id: test_post_id} + payload = {tweet_id: testPostId} ); test:assertTrue(response?.data !is ()); test:assertTrue(response?.errors is ()); @@ -97,7 +97,7 @@ isolated function testBookmarkPost() returns error? { groups: ["live_tests", "mock_tests"] } isolated function testBookmarkDelete() returns error? { - BookmarkMutationResponse response = check twitter->/users/[userId]/bookmarks/[test_post_id].delete(); + BookmarkMutationResponse response = check twitter->/users/[userId]/bookmarks/[testPostId].delete(); test:assertTrue(response?.data !is ()); test:assertTrue(response?.errors is ()); } @@ -107,7 +107,7 @@ isolated function testBookmarkDelete() returns error? { } isolated function testRetweet() returns error? { UsersRetweetsCreateResponse response = check twitter->/users/[userId]/retweets.post( - payload = {tweet_id: test_post_id} + payload = {tweet_id: testPostId} ); test:assertTrue(response?.data !is ()); test:assertTrue(response?.errors is ()); @@ -117,7 +117,7 @@ isolated function testRetweet() returns error? { groups: ["live_tests", "mock_tests"] } isolated function testDeleteRetweet() returns error? { - UsersRetweetsDeleteResponse response = check twitter->/users/[userId]/retweets/[test_post_id].delete(); + UsersRetweetsDeleteResponse response = check twitter->/users/[userId]/retweets/[testPostId].delete(); test:assertTrue(response?.data !is ()); test:assertTrue(response?.errors is ()); } @@ -128,7 +128,7 @@ isolated function testDeleteRetweet() returns error? { isolated function testFollowSpecificUser() returns error? { UsersFollowingCreateResponse response = check twitter->/users/[userId]/following.post( payload = { - target_user_id: test_user_id + target_user_id: testUserId } ); test:assertTrue(response?.data !is ()); @@ -139,7 +139,7 @@ isolated function testFollowSpecificUser() returns error? { groups: ["live_tests", "mock_tests"] } isolated function testUnfollowSpecificUser() returns error? { - UsersFollowingDeleteResponse response = check twitter->/users/[userId]/following/[test_user_id].delete(); + UsersFollowingDeleteResponse response = check twitter->/users/[userId]/following/[testUserId].delete(); test:assertTrue(response?.data !is ()); test:assertTrue(response?.errors is ()); } @@ -150,7 +150,7 @@ isolated function testUnfollowSpecificUser() returns error? { isolated function muteSpecificUser() returns error? { MuteUserMutationResponse response = check twitter->/users/[userId]/muting.post( payload = { - target_user_id: test_user_id + target_user_id: testUserId } ); test:assertTrue(response?.data !is ()); @@ -162,7 +162,7 @@ isolated function muteSpecificUser() returns error? { } isolated function unmuteSpecificUser() returns error? { - MuteUserMutationResponse response = check twitter->/users/[userId]/muting/[test_user_id].delete(); + MuteUserMutationResponse response = check twitter->/users/[userId]/muting/[testUserId].delete(); test:assertTrue(response?.data !is ()); test:assertTrue(response?.errors is ()); } @@ -171,7 +171,7 @@ isolated function unmuteSpecificUser() returns error? { groups: ["live_tests", "mock_tests"] } isolated function findSpecificUser() returns error? { - Get2UsersResponse response = check twitter->/users(ids = [test_user_id]); + Get2UsersResponse response = check twitter->/users(ids = [testUserId]); test:assertTrue(response?.data !is ()); test:assertTrue(response?.errors is ()); }