Files
Igor Sirotin f9cc782a6f refactor: move services to pkg/services
Part of the Go project layout migration, item 31.

Pure move plus import-path rewrite across 687 files. No API or behaviour
change.

The services keep their grouping under pkg/services/<name> rather than
being promoted to pkg/<name>: 27 top-level directories in pkg/ would read
worse than what we have, and the grouping is what makes "an RPC service"
identifiable at a glance.

Paths that follow the move: the logosstorage test target and generate
step, the two wallet token-list tools, the migration-order check (and the
pre-rebase hook symlinked to it), and the storage env helper.

refs #7067
2026-08-21 10:11:05 +02:00

79 lines
1.8 KiB
Go

package browsers
import (
"context"
"testing"
"github.com/stretchr/testify/require"
"github.com/status-im/status-go/internal/db/appdatabase"
"github.com/status-im/status-go/internal/testutils"
)
func setupTestDB(t *testing.T) (*Database, func()) {
db, cleanup, err := testutils.SetupTestSQLDB(appdatabase.DbInitializer{}, "browsers-tests")
require.NoError(t, err)
return NewDB(db), func() { require.NoError(t, cleanup()) }
}
func setupTestAPI(t *testing.T) (*API, func()) {
db, cancel := setupTestDB(t)
return &API{db: db}, cancel
}
func TestBookmarks(t *testing.T) {
api, cancel := setupTestAPI(t)
defer cancel()
bookmark := &Bookmark{
Name: "MyBookmark",
URL: "https://status.im",
ImageURL: "",
}
_, err := api.StoreBookmark(context.TODO(), *bookmark)
require.NoError(t, err)
rst, err := api.GetBookmarks(context.TODO())
require.NoError(t, err)
require.Len(t, rst, 1)
err = api.RemoveBookmark(context.TODO(), bookmark.URL)
require.NoError(t, err)
rst, err = api.GetBookmarks(context.TODO())
require.NoError(t, err)
require.Len(t, rst, 1)
require.Equal(t, rst[0].Removed, true)
require.NoError(t, api.DeleteBookmark(context.TODO(), bookmark.URL))
rst, err = api.GetBookmarks(context.TODO())
require.NoError(t, err)
require.Len(t, rst, 0)
}
func TestShouldSyncBookmark(t *testing.T) {
api, cancel := setupTestAPI(t)
defer cancel()
bookmark := &Bookmark{
Name: "MyBookmark",
URL: "https://status.im",
ImageURL: "",
Clock: 1,
}
_, err := api.StoreBookmark(context.TODO(), *bookmark)
require.NoError(t, err)
bookmark.Clock = 2
shouldSync, err := api.db.shouldSyncBookmark(bookmark, nil)
require.NoError(t, err)
require.True(t, shouldSync)
bookmark.Clock = 0
shouldSync, err = api.db.shouldSyncBookmark(bookmark, nil)
require.NoError(t, err)
require.False(t, shouldSync)
}