Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Merge c21143a into 3754411
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanie-engel committed Aug 5, 2019
2 parents 3754411 + c21143a commit 90e991e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
13 changes: 13 additions & 0 deletions test/cache_fs.js
Expand Up @@ -196,6 +196,19 @@ describe("Cache: FS", () => {
assert(await fs.pathExists(file.path));
});

it("should delete any files if the dryRun option is false", async () => {
const opts = Object.assign({}, cacheOpts);
opts.cleanupOptions = {
expireTimeSpan: "P30D",
maxCacheSize: 1
};

await cache.init(opts);
const file = await addFileToCache(moment().toDate());
await cache.cleanup(false);
assert(!await fs.pathExists(file.path));
});

it("should remove versions from the reliability manager, when in high reliability mode", async () => {
const opts = Object.assign({}, cacheOpts);
opts.cleanupOptions = {
Expand Down
11 changes: 9 additions & 2 deletions test/reliability_manager.js
Expand Up @@ -104,13 +104,14 @@ describe("ReliabilityManager", () => {
});

describe("Known version, reliabilityFactor exceeds reliabilityThreshold", () => {
let trx;
let trx, trxSpy;
before(async () => {
const guid = randomBuffer(consts.GUID_SIZE);
const hash = randomBuffer(consts.HASH_SIZE);
await rm.processTransaction(new StablePutTransaction(guid, hash)); // once
await rm.processTransaction(new StablePutTransaction(guid, hash)); // twice
trx = new StablePutTransaction(guid, hash);
trxSpy = sinon.spy(trx, "writeFilesToPath");
assert(trx.isValid);
await rm.processTransaction(trx); // three times (last time)
});
Expand All @@ -125,6 +126,10 @@ describe("ReliabilityManager", () => {
it("should invalidate the transaction to prevent changes to the version", () => {
assert(!trx.isValid);
});

it("should not tell the cache to write unreliable files", () => {
assert(!trxSpy.called);
});
});

describe("Known version, inconsistent versionHash", () => {
Expand All @@ -150,10 +155,12 @@ describe("ReliabilityManager", () => {
assert(!trx.isValid);
});

// seperated this into 2 tests
it("should tell the transaction to write unreliable files if saveUnreliableVersionArtifacts is true", async () => {
assert(spy.called);
});

// Test with saveUnreliableVersionArtifacts = false
it("should not tell the transaction to write unreliable files if saveUnreliableVersionArtifacts is false", async () => {
const myRm = new ReliabilityManager(db, tmp.tmpNameSync(), {reliabilityThreshold: 2, saveUnreliableVersionArtifacts: false});
spy.resetHistory();
await myRm.processTransaction(trx);
Expand Down

0 comments on commit 90e991e

Please sign in to comment.