Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

Commit

Permalink
fix(index): set default hashAlgorithm
Browse files Browse the repository at this point in the history
omfg config really needs to be more centralized soon
  • Loading branch information
zkat committed Mar 13, 2017
1 parent 2318a8f commit d6eb2f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/entry-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function insert (cache, key, digest, opts) {
const entry = {
key: key,
digest: digest,
hashAlgorithm: opts.hashAlgorithm,
hashAlgorithm: opts.hashAlgorithm || 'sha512',
time: +(new Date()),
metadata: opts.metadata
}
Expand Down
12 changes: 9 additions & 3 deletions test/index.insert.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ test('inserts additional entries into existing key', function (t) {
t.deepEqual(entries, [{
key: KEY,
digest: DIGEST,
hashAlgorithm: 'sha512',
metadata: 1
}, {
key: KEY,
digest: DIGEST,
hashAlgorithm: 'sha512',
metadata: 2
}], 'all entries present')
})
Expand All @@ -91,7 +93,8 @@ test('separates entries even if one is corrupted', function (t) {
delete entry.time
t.deepEqual(entry, {
key: KEY,
digest: DIGEST
digest: DIGEST,
hashAlgorithm: 'sha512'
}, 'new entry unaffected by corruption')
})
})
Expand All @@ -108,6 +111,7 @@ test('optional arbitrary metadata', function (t) {
t.deepEqual(entry, {
key: KEY,
digest: DIGEST,
hashAlgorithm: 'sha512',
metadata: metadata
}, 'entry includes inserted metadata')
})
Expand Down Expand Up @@ -155,7 +159,8 @@ test('path-breaking characters', function (t) {
delete entry.time
t.deepEqual(entry, {
key: newKey,
digest: DIGEST
digest: DIGEST,
hashAlgorithm: 'sha512'
}, 'entry exists and matches original key with invalid chars')
})
})
Expand All @@ -175,7 +180,8 @@ test('extremely long keys', function (t) {
delete entry.time
t.deepEqual(entry, {
key: newKey,
digest: DIGEST
digest: DIGEST,
hashAlgorithm: 'sha512'
}, 'entry exists in spite of INCREDIBLY LONG key')
})
})
Expand Down

0 comments on commit d6eb2f0

Please sign in to comment.