Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix: make clear pins function in tests serial
Browse files Browse the repository at this point in the history
refs #1890

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
  • Loading branch information
Alan Shaw committed Mar 6, 2019
1 parent 3fff46a commit d34aa3f
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions test/core/pin.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,18 @@ describe('pin', function () {
.then(result => expect(result.pinned).to.eql(pinned))
}

function clearPins () {
return pin.ls()
.then(ls => {
const pinsToRemove = ls
.filter(out => out.type === pinTypes.recursive)
.map(out => pin.rm(out.hash))
return Promise.all(pinsToRemove)
})
.then(() => pin.ls())
.then(ls => {
const pinsToRemove = ls
.filter(out => out.type === pinTypes.direct)
.map(out => pin.rm(out.hash))
return Promise.all(pinsToRemove)
})
async function clearPins () {
let ls = (await pin.ls()).filter(out => out.type === pinTypes.recursive)

for (let i = 0; i < ls.length; i++) {
await pin.rm(ls[i].hash)
}

ls = (await pin.ls()).filter(out => out.type === pinTypes.direct)

for (let i = 0; i < ls.length; i++) {
await pin.rm(ls[i].hash)
}
}

before(function (done) {
Expand Down

0 comments on commit d34aa3f

Please sign in to comment.