2024-08-25 22:54:18 -07:00
|
|
|
package persistence_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/go-test/deep"
|
2024-09-02 15:02:27 -07:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
2025-02-10 13:30:01 -08:00
|
|
|
. "gitlab.com/offline-twitter/twitter_offline_engine/pkg/persistence"
|
2024-09-02 16:25:54 -07:00
|
|
|
. "gitlab.com/offline-twitter/twitter_offline_engine/pkg/scraper"
|
2024-08-25 22:54:18 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestSaveAndLoadNotification(t *testing.T) {
|
|
|
|
profile_path := "test_profiles/TestNotificationQuery"
|
|
|
|
profile := create_or_load_profile(profile_path)
|
|
|
|
|
|
|
|
// Save it
|
|
|
|
n := create_dummy_notification()
|
|
|
|
profile.SaveNotification(n)
|
|
|
|
|
|
|
|
// Check it comes back the same
|
|
|
|
new_n := profile.GetNotification(n.ID)
|
|
|
|
if diff := deep.Equal(n, new_n); diff != nil {
|
|
|
|
t.Error(diff)
|
|
|
|
}
|
|
|
|
}
|
2024-09-02 15:02:27 -07:00
|
|
|
|
|
|
|
func TestGetUnreadNotificationsCount(t *testing.T) {
|
|
|
|
require := require.New(t)
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
2025-02-10 13:30:01 -08:00
|
|
|
profile, err := LoadProfile("../../sample_data/profile")
|
2024-09-02 15:02:27 -07:00
|
|
|
require.NoError(err)
|
|
|
|
|
2024-09-02 16:25:54 -07:00
|
|
|
unread_notifs_count := profile.GetUnreadNotificationsCount(UserID(1488963321701171204), 1724372973735)
|
2024-09-02 15:02:27 -07:00
|
|
|
assert.Equal(2, unread_notifs_count)
|
|
|
|
}
|