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 (#1910)
Browse files Browse the repository at this point in the history
refs #1890

License: MIT
Signed-off-by: Alan Shaw <[email protected]>
  • Loading branch information
Alan Shaw authored Mar 6, 2019
1 parent 9470900 commit 503e5ac
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 503e5ac

Please sign in to comment.