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

fix: make clear pins function in tests serial #1910

Merged
merged 1 commit into from
Mar 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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