diff --git a/persistence/tweet_queries_test.go b/persistence/tweet_queries_test.go index eb44df5..5dc6e81 100644 --- a/persistence/tweet_queries_test.go +++ b/persistence/tweet_queries_test.go @@ -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) } diff --git a/persistence/user_queries.go b/persistence/user_queries.go index f4a54b7..d8168e7 100644 --- a/persistence/user_queries.go +++ b/persistence/user_queries.go @@ -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 diff --git a/persistence/user_queries_test.go b/persistence/user_queries_test.go index 52e85cf..c687151 100644 --- a/persistence/user_queries_test.go +++ b/persistence/user_queries_test.go @@ -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 */