Skip to content

Commit

Permalink
add unit tests (#42)
Browse files Browse the repository at this point in the history
g8rswimmer authored Jan 4, 2021

Verified

This commit was signed with the committer’s verified signature.
haythemsellami Haythem Sellami
1 parent df4a984 commit 3a4a858
Showing 2 changed files with 37 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tweet.go
Original file line number Diff line number Diff line change
@@ -13,10 +13,10 @@ import (
const (
tweetLookupEndpoint = "2/tweets"
tweetRecentSearchEndpoint = "2/tweets/search/recent"
tweetFilteredStreamRulesEndpoint = "/2/tweets/search/stream/rules"
tweetFilteredStreamEndpoint = "/2/tweets/search/stream"
tweetSampledStreamEndpoint = "/2/tweets/sample/stream"
tweetHideEndpoint = "/2/tweets/{id}/hidden"
tweetFilteredStreamRulesEndpoint = "2/tweets/search/stream/rules"
tweetFilteredStreamEndpoint = "2/tweets/search/stream"
tweetSampledStreamEndpoint = "2/tweets/sample/stream"
tweetHideEndpoint = "2/tweets/{id}/hidden"
tweetID = "{id}"
tweetMaxIDs = 100
tweetQuerySize = 512
33 changes: 33 additions & 0 deletions tweet_test.go
Original file line number Diff line number Diff line change
@@ -549,6 +549,9 @@ func TestTweet_UpdateSearchStreamRules(t *testing.T) {
if strings.Contains(req.URL.String(), tweetFilteredStreamRulesEndpoint) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), tweetFilteredStreamRulesEndpoint)
}
if strings.Contains(req.URL.String(), "//2/tweets") {
log.Panicf("the url is not correct %s", req.URL.String())
}

body := `{
"data": [
@@ -652,6 +655,9 @@ func TestTweet_UpdateSearchStreamRules(t *testing.T) {
if strings.Contains(req.URL.String(), tweetFilteredStreamRulesEndpoint) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), tweetFilteredStreamRulesEndpoint)
}
if strings.Contains(req.URL.String(), "//2/tweets") {
log.Panicf("the url is not correct %s", req.URL.String())
}
body := `{
"meta": {
"sent": "2019-08-29T01:48:54.633Z",
@@ -697,6 +703,9 @@ func TestTweet_UpdateSearchStreamRules(t *testing.T) {
if strings.Contains(req.URL.String(), tweetFilteredStreamRulesEndpoint) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), tweetFilteredStreamRulesEndpoint)
}
if strings.Contains(req.URL.String(), "//2/tweets") {
log.Panicf("the url is not correct %s", req.URL.String())
}
body := `{
"title": "Invalid Request",
"detail": "One or more parameters to your request was invalid.",
@@ -793,6 +802,9 @@ func TestTweet_SearchStreamRules(t *testing.T) {
if strings.Contains(req.URL.String(), tweetFilteredStreamRulesEndpoint) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), tweetFilteredStreamRulesEndpoint)
}
if strings.Contains(req.URL.String(), "//2/tweets") {
log.Panicf("the url is not correct %s", req.URL.String())
}
body := `{
"data": [
{
@@ -847,6 +859,9 @@ func TestTweet_SearchStreamRules(t *testing.T) {
if strings.Contains(req.URL.String(), tweetFilteredStreamRulesEndpoint) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), tweetFilteredStreamRulesEndpoint)
}
if strings.Contains(req.URL.String(), "//2/tweets") {
log.Panicf("the url is not correct %s", req.URL.String())
}
body := `{
"title": "Invalid Request",
"detail": "One or more parameters to your request was invalid.",
@@ -925,6 +940,9 @@ func TestTweet_SearchStream(t *testing.T) {
if strings.Contains(req.URL.String(), tweetFilteredStreamEndpoint) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), tweetFilteredStreamEndpoint)
}
if strings.Contains(req.URL.String(), "//2/tweets") {
log.Panicf("the url is not correct %s", req.URL.String())
}
body := `{
"data": {
"id": "1067094924124872705",
@@ -968,6 +986,9 @@ func TestTweet_SearchStream(t *testing.T) {
if strings.Contains(req.URL.String(), tweetFilteredStreamEndpoint) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), tweetFilteredStreamEndpoint)
}
if strings.Contains(req.URL.String(), "//2/tweets") {
log.Panicf("the url is not correct %s", req.URL.String())
}
body := `{
"title": "Invalid Request",
"detail": "One or more parameters to your request was invalid.",
@@ -1044,6 +1065,9 @@ func TestTweet_SampledStream(t *testing.T) {
if strings.Contains(req.URL.String(), tweetSampledStreamEndpoint) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), tweetSampledStreamEndpoint)
}
if strings.Contains(req.URL.String(), "//2/tweets") {
log.Panicf("the url is not correct %s", req.URL.String())
}
body := `{
"data": {
"id": "1067094924124872705",
@@ -1087,6 +1111,9 @@ func TestTweet_SampledStream(t *testing.T) {
if strings.Contains(req.URL.String(), tweetSampledStreamEndpoint) == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), tweetSampledStreamEndpoint)
}
if strings.Contains(req.URL.String(), "//2/tweets") {
log.Panicf("the url is not correct %s", req.URL.String())
}
body := `{
"title": "Invalid Request",
"detail": "One or more parameters to your request was invalid.",
@@ -1163,6 +1190,9 @@ func TestTweet_Hide(t *testing.T) {
if strings.Contains(req.URL.String(), "hidden") == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), "hidden")
}
if strings.Contains(req.URL.String(), "//2/tweets") {
log.Panicf("the url is not correct %s", req.URL.String())
}
body := `{"data":{"hidden":true}}`
return &http.Response{
StatusCode: http.StatusOK,
@@ -1188,6 +1218,9 @@ func TestTweet_Hide(t *testing.T) {
if strings.Contains(req.URL.String(), "hidden") == false {
log.Panicf("the url is not correct %s %s", req.URL.String(), "hidden")
}
if strings.Contains(req.URL.String(), "//2/tweets") {
log.Panicf("the url is not correct %s", req.URL.String())
}
body := `{"data":{"hidden":false}}`
return &http.Response{
StatusCode: http.StatusOK,

0 comments on commit 3a4a858

Please sign in to comment.