fix: repostore started flag in stop() (#374)
This commit is contained in:
parent
086b5c3914
commit
c9a62de13f
|
@ -371,8 +371,7 @@ proc start*(self: RepoStore): Future[void] {.async.} =
|
|||
proc stop*(self: RepoStore): Future[void] {.async.} =
|
||||
## Stop repo
|
||||
##
|
||||
|
||||
if self.started:
|
||||
if not self.started:
|
||||
trace "Repo is not started"
|
||||
return
|
||||
|
||||
|
@ -380,6 +379,8 @@ proc stop*(self: RepoStore): Future[void] {.async.} =
|
|||
(await self.repoDs.close()).expect("Should close repo store!")
|
||||
(await self.metaDs.close()).expect("Should close meta store!")
|
||||
|
||||
self.started = false
|
||||
|
||||
func new*(
|
||||
T: type RepoStore,
|
||||
repoDs: Datastore,
|
||||
|
|
|
@ -22,6 +22,39 @@ import ../helpers
|
|||
import ../helpers/mockclock
|
||||
import ./commonstoretests
|
||||
|
||||
suite "Test RepoStore start/stop":
|
||||
|
||||
var
|
||||
repoDs: Datastore
|
||||
metaDs: Datastore
|
||||
|
||||
setup:
|
||||
repoDs = SQLiteDatastore.new(Memory).tryGet()
|
||||
metaDs = SQLiteDatastore.new(Memory).tryGet()
|
||||
|
||||
test "Should set started flag once started":
|
||||
let repo = RepoStore.new(repoDs, metaDs, quotaMaxBytes = 200)
|
||||
await repo.start()
|
||||
check repo.started
|
||||
|
||||
test "Should set started flag to false once stopped":
|
||||
let repo = RepoStore.new(repoDs, metaDs, quotaMaxBytes = 200)
|
||||
await repo.start()
|
||||
await repo.stop()
|
||||
check not repo.started
|
||||
|
||||
test "Should allow start to be called multiple times":
|
||||
let repo = RepoStore.new(repoDs, metaDs, quotaMaxBytes = 200)
|
||||
await repo.start()
|
||||
await repo.start()
|
||||
check repo.started
|
||||
|
||||
test "Should allow stop to be called multiple times":
|
||||
let repo = RepoStore.new(repoDs, metaDs, quotaMaxBytes = 200)
|
||||
await repo.stop()
|
||||
await repo.stop()
|
||||
check not repo.started
|
||||
|
||||
suite "RepoStore":
|
||||
var
|
||||
repoDs: Datastore
|
||||
|
|
Loading…
Reference in New Issue