add logging of context store

This commit is contained in:
Hiroyasu Nishiyama
2018-07-19 07:40:52 +09:00
parent cecea318da
commit 31ee1be81e
9 changed files with 104 additions and 4 deletions

View File

@@ -18,6 +18,7 @@ var should = require("should");
var sinon = require('sinon');
var path = require("path");
var Context = require("../../../../../red/runtime/nodes/context/index");
var Log = require("../../../../../red/runtime/log");
describe('context', function() {
describe('local memory',function() {
@@ -792,4 +793,37 @@ describe('context', function() {
});
});
});
describe('log', function() {
it('should log context store info', function(done) {
Context.init({
contextStorage: {
memory: {
module: "memory",
congig: {
}
}
}
});
Context.load().then(function() {
var loginfo = undefined;
var logmsg = undefined;
sinon.stub(Log, 'log', function(msg) {
loginfo = msg;
});
sinon.stub(Log, '_', function(msg, info) {
logmsg = JSON.stringify(info);
return logmsg;
});
Context.logStores();
should.deepEqual(loginfo, {
level: Log.INFO,
msg: logmsg
});
Log.log.restore();
Log._.restore();
done();
});
});
});
});

View File

@@ -376,7 +376,7 @@ describe('localfilesystem',function() {
});
});
describe('if cache is enabled',function() {
describe('#if cache is enabled',function() {
afterEach(function() {
return context.clean([]).then(function(){
return context.close().then(function(){
@@ -496,4 +496,12 @@ describe('localfilesystem',function() {
});
});
});
describe('#info', function() {
it('should return info', function() {
var context = LocalFileSystem({dir: "/tmp", base: "xyz", cache: true});
var info = context.info();
info.should.be.equal("module=localfilesystem,base='xyz',dir='/tmp',cache");
});
});
});

View File

@@ -214,4 +214,11 @@ describe('memory',function() {
});
});
describe('#info',function() {
it('should return info', function() {
var info = context.info();
info.should.be.equal("module=memory");
});
});
});