Make user handles case insensitive
This commit is contained in:
parent
a2554e9293
commit
1dc9511415
@ -29,6 +29,12 @@ func TestSaveAndLoadTweet(t *testing.T) {
|
||||
t.Fatalf("Failed to load the tweet: %s", err.Error())
|
||||
}
|
||||
|
||||
if diff := deep.Equal(tweet.Images, new_tweet.Images); diff != nil {
|
||||
t.Error(diff)
|
||||
}
|
||||
if diff := deep.Equal(tweet.Videos, new_tweet.Videos); diff != nil {
|
||||
t.Error(diff)
|
||||
}
|
||||
if diff := deep.Equal(tweet, new_tweet); diff != nil {
|
||||
t.Error(diff)
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ func (p Profile) GetUserByHandle(handle scraper.UserHandle) (scraper.User, error
|
||||
stmt, err := db.Prepare(`
|
||||
select id, display_name, handle, bio, following_count, followers_count, location, website, join_date, is_private, is_verified, profile_image_url, profile_image_local_path, banner_image_url, banner_image_local_path, pinned_tweet_id, is_content_downloaded
|
||||
from users
|
||||
where handle = ?
|
||||
where lower(handle) = lower(?)
|
||||
`)
|
||||
if err != nil {
|
||||
return scraper.User{}, err
|
||||
|
@ -42,6 +42,23 @@ func TestSaveAndLoadUser(t *testing.T) {
|
||||
}
|
||||
|
||||
|
||||
func TestHandleIsCaseInsensitive(t *testing.T) {
|
||||
profile_path := "test_profiles/TestUserQueries"
|
||||
profile := create_or_load_profile(profile_path)
|
||||
|
||||
user := create_stable_user()
|
||||
|
||||
new_user, err := profile.GetUserByHandle("hANdle StaBlE")
|
||||
if err != nil {
|
||||
t.Fatalf("Couldn't find the user: %s", err.Error())
|
||||
}
|
||||
|
||||
if diff := deep.Equal(user, new_user); diff != nil {
|
||||
t.Error(diff)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Should correctly report whether the user exists in the database
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user