mirror of
https://github.com/logos-storage/logos-storage-network-crawler.git
synced 2026-01-02 13:33:08 +00:00
47 lines
1.0 KiB
Nim
47 lines
1.0 KiB
Nim
import pkg/chronos
|
|
import pkg/questionable/results
|
|
|
|
import ../../../codexcrawler/types
|
|
import ../../../codexcrawler/list
|
|
|
|
type MockList* = ref object of List
|
|
loadCalled*: bool
|
|
added*: seq[Nid]
|
|
addSuccess*: bool
|
|
removed*: seq[Nid]
|
|
removeSuccess*: bool
|
|
length*: int
|
|
|
|
method load*(this: MockList): Future[?!void] {.async: (raises: [CancelledError]).} =
|
|
this.loadCalled = true
|
|
return success()
|
|
|
|
method add*(
|
|
this: MockList, nid: Nid
|
|
): Future[?!void] {.async: (raises: [CancelledError]).} =
|
|
this.added.add(nid)
|
|
if this.addSuccess:
|
|
return success()
|
|
return failure("test failure")
|
|
|
|
method remove*(
|
|
this: MockList, nid: Nid
|
|
): Future[?!void] {.async: (raises: [CancelledError]).} =
|
|
this.removed.add(nid)
|
|
if this.removeSuccess:
|
|
return success()
|
|
return failure("test failure")
|
|
|
|
method len*(this: MockList): int =
|
|
return this.length
|
|
|
|
proc createMockList*(): MockList =
|
|
MockList(
|
|
loadCalled: false,
|
|
added: newSeq[Nid](),
|
|
addSuccess: true,
|
|
removed: newSeq[Nid](),
|
|
removeSuccess: true,
|
|
length: 0,
|
|
)
|