status-lib/backends/mock/bookmark.nim

24 lines
761 B
Nim
Raw Normal View History

import tables, sequtils
import types
import ../../types/[bookmark], json, chronicles
import ../backend_type
var bookmarks_storage_mock = initTable[string, Bookmark]()
method storeBookmark*(self: MockBackend, bookmark: Bookmark): Bookmark =
result = bookmark
bookmarks_storage_mock[bookmark.url] = bookmark
method updateBookmark*(self: MockBackend, originalUrl: string, bookmark: Bookmark) =
bookmarks_storage_mock.del(originalUrl)
bookmarks_storage_mock[bookmark.url] = bookmark
method getBookmarks*(self: MockBackend): seq[Bookmark] =
var bookmarks: seq[Bookmark] = @[]
for b in bookmarks_storage_mock.values:
bookmarks.add(b)
result = bookmarks
method deleteBookmark*(self: MockBackend, url: string) =
bookmarks_storage_mock.del(url)