From 3a4a858d69ec7c84c8edee5c5641ee4e2eb4ac6e Mon Sep 17 00:00:00 2001 From: Sean <34941871+g8rswimmer@users.noreply.github.com> Date: Sun, 3 Jan 2021 19:29:36 -0700 Subject: [PATCH] add unit tests (#42) --- tweet.go | 8 ++++---- tweet_test.go | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/tweet.go b/tweet.go index 751498f..8cf30b6 100644 --- a/tweet.go +++ b/tweet.go @@ -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 diff --git a/tweet_test.go b/tweet_test.go index e45729d..4505be9 100644 --- a/tweet_test.go +++ b/tweet_test.go @@ -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,