mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-15 23:24:52 +09:00
Implement hashStream
Add a hashStream method to lib/hash that does the same as hashFile only with a stream instead of a file path and implement tests for both of these methods.
This commit is contained in:
1 parent
e6d995d97a
commit
079e31cf05
4 files changed
+45
-4
No files matched your search
@@ -0,0 +1 @@
|
||||
The quick brown fox jumps over the lazy dog
|
||||
@@ -0,0 +1,24 @@
|
||||
const assert = require('assert').strict;
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const stream = require('stream');
|
||||
|
||||
const hash = require('lib/hash');
|
||||
|
||||
|
||||
describe("lib/hash", function() {
|
||||
describe("hashStream()", function() {
|
||||
it("should hash a stream of bytes", async function() {
|
||||
let stream = fs.createReadStream(path.join("test", "file", "hash.txt"));
|
||||
let result = await hash.hashStream(stream);
|
||||
assert.equal(result, "be417768b5c3c5c1d9bcb2e7c119196dd76b5570");
|
||||
});
|
||||
});
|
||||
|
||||
describe("hashFile()", function() {
|
||||
it("should hash a file", async function() {
|
||||
let result = await hash.hashFile(path.join("test", "file", "hash.txt"));
|
||||
assert.equal(result, "be417768b5c3c5c1d9bcb2e7c119196dd76b5570");
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -4,7 +4,6 @@
|
||||
require('lib/clusterTools');
|
||||
require('lib/dole_nn_base');
|
||||
require('lib/getInstances');
|
||||
require('lib/hash');
|
||||
require('lib/manager/instanceManager');
|
||||
require('lib/manager/modManager');
|
||||
require('lib/manager/pluginManager');
|
||||
|
||||
Reference in new issue
Block a user