Last active
May 1, 2020 14:22
-
-
Save ldclakmal/9010db69e72ee82fb725dc09d21a980e to your computer and use it in GitHub Desktop.
Twitter Client Test in Ballerina
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ballerina/io; | |
import ballerina/test; | |
Configuration twitterConfig = { | |
consumerKey: "Twitter App Consumer Key", | |
consumerSecret: "Twitter App Consumer Secret", | |
accessToken: "Twitter App Access Token", | |
accessTokenSecret: "Twitter App Access Token Secret", | |
}; | |
Client twitterClient = new(twitterConfig); | |
@test:Config {} | |
function testTweet() { | |
string status = "Welcome to Ballerina Twitter Connector!"; | |
var tweetResponse = twitterClient->tweet(status); | |
if (tweetResponse is Status) { | |
test:assertEquals(tweetResponse.text, status, "Failed to call tweet()"); | |
io:println(tweetResponse); | |
} else { | |
test:assertFail(<string>tweetResponse.detail()["message"]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment