Add linting

This commit is contained in:
Alessio 2021-06-14 13:08:38 -07:00
parent 5b7d3dcdc4
commit 5290a0b549
5 changed files with 26 additions and 2 deletions

View File

@ -27,3 +27,21 @@ tasks:
cd twitter_offline_engine/scraper
go test -bench=.
- install_golangci-lint: |
SECONDS=0
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/local/go/bin v1.40.1
sudo ln /usr/local/go/bin/golangci-lint /usr/bin/golangci-lint
duration=$SECONDS
echo "Task completed in $(($duration / 60))m$(($duration % 60))s."
- run_lint: |
SECONDS=0
cd twitter_offline_engine/scraper
golangci-lint run
duration=$SECONDS
echo "Task completed in $(($duration / 60))m$(($duration % 60))s."

View File

@ -142,7 +142,7 @@ type TweetResponse struct {
Cursor struct {
Value string `json:"value"`
} `json:"cursor"`
} `json:"operation`
} `json:"operation"`
} `json:"content"`
} `json:"entries"`
} `json:"addEntries"`

View File

@ -22,6 +22,6 @@ func TestGetGuestToken(t *testing.T) {
// other than the first use the cache.
func BenchmarkGetGuestToken(b *testing.B) {
for i := 0; i < b.N; i++ {
scraper.GetGuestToken()
_, _ = scraper.GetGuestToken()
}
}

View File

@ -20,6 +20,9 @@ func TestParseSingleRetweet(t *testing.T) {
}
retweet, err := scraper.ParseSingleRetweet(api_tweet)
if err != nil {
t.Errorf(err.Error())
}
if retweet.RetweetID != scraper.TweetID("1404270043018448896") {
t.Errorf("Expected %q, got %q", scraper.TweetID("1404270043018448896"), retweet.RetweetID)

View File

@ -21,6 +21,9 @@ func TestParseSingleUser(t *testing.T) {
apiUser := user_resp.ConvertToAPIUser()
user, err := scraper.ParseSingleUser(apiUser)
if err != nil {
t.Errorf(err.Error())
}
if user.ID != "44067298" {
t.Errorf("Expected %q, got %q", "44067298", user.ID)