From ba3034b3cf51b7526156b215ba3388486c81ab8e Mon Sep 17 00:00:00 2001 From: nkanaev Date: Thu, 18 Jun 2026 14:28:24 +0100 Subject: [PATCH] storage test fixes --- src/storage/postgres/item.go | 2 +- src/storage/sqlite/item.go | 2 +- src/storage/tests/item_test.go | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/storage/postgres/item.go b/src/storage/postgres/item.go index 7eeacd2..4fa1ef5 100644 --- a/src/storage/postgres/item.go +++ b/src/storage/postgres/item.go @@ -72,7 +72,7 @@ func (s *PostgresStorage) CreateItems(items []model.Item) bool { MediaLinks(item.MediaLinks), now, now, - model.UNREAD, + item.Status, searchText, ) if err != nil { diff --git a/src/storage/sqlite/item.go b/src/storage/sqlite/item.go index 32795e0..87987d5 100644 --- a/src/storage/sqlite/item.go +++ b/src/storage/sqlite/item.go @@ -69,7 +69,7 @@ func (s *SQLiteStorage) CreateItems(items []model.Item) bool { sql.Named("media_links", MediaLinks(item.MediaLinks)), sql.Named("date_arrived", now), sql.Named("last_arrived", now), - sql.Named("status", model.UNREAD), + sql.Named("status", item.Status), ) if err != nil { log.Print(err) diff --git a/src/storage/tests/item_test.go b/src/storage/tests/item_test.go index 9344728..0dad182 100644 --- a/src/storage/tests/item_test.go +++ b/src/storage/tests/item_test.go @@ -246,10 +246,15 @@ func TestListItems(t *testing.T) { func TestListItemsPaginated(t *testing.T) { dbtest(t, func(t *testing.T, db storage.Storage) { - scope := testItemsSetup(db) + testItemsSetup(db) - item012 := MustGet(scope.items, "item012") - item121 := MustGet(scope.items, "item121") + itemsByGUID := make(map[string]model.Item) + for _, item := range db.ListItems(model.ItemFilter{}, 1000, false, false) { + itemsByGUID[item.GUID] = item + } + + item012 := MustGet(itemsByGUID, "item012") + item121 := MustGet(itemsByGUID, "item121") // all, newest first have := getItemGuids(db.ListItems(model.ItemFilter{After: &item012.Id}, 3, true, false))