offline-twitter/pkg/scraper/guest_token_test.go

29 lines
714 B
Go
Raw Normal View History

2021-05-17 12:59:10 -04:00
package scraper_test
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
. "gitlab.com/offline-twitter/twitter_offline_engine/pkg/scraper"
)
2021-05-17 12:59:10 -04:00
// Makes an HTTP request
func TestGetGuestToken(t *testing.T) {
token, err := GetGuestToken()
require.NoError(t, err)
2021-05-17 12:59:10 -04:00
assert.True(t, len(token) >= 15, "I don't think this is a token: %q", token)
2021-05-17 12:59:10 -04:00
fmt.Println(token)
}
// Tests the caching. Should run much much faster than an HTTP request, since all requests
// other than the first use the cache.
func BenchmarkGetGuestToken(b *testing.B) {
for i := 0; i < b.N; i++ {
GetGuestToken() //nolint:errcheck // Don't care about errors, just want to time it
2021-05-17 12:59:10 -04:00
}
}