Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / log4js / test / log-abspath-test.js
1 "use strict";
2 var vows = require('vows')
3 , assert = require('assert')
4 , path = require('path')
5 , sandbox = require('sandboxed-module');
6
7 vows.describe('log4js-abspath').addBatch({
8   'options': {
9     topic: function() {
10       var appenderOptions,
11       log4js = sandbox.require(
12         '../lib/log4js',
13         { requires:
14           { './appenders/fake':
15             { name: "fake",
16               appender: function() {},
17               configure: function(configuration, options) {
18                 appenderOptions = options;
19                 return function() {};
20               }
21             }
22           }
23         }
24       ),
25       config = {
26         "appenders": [
27           {
28             "type" : "fake",
29             "filename" : "cheesy-wotsits.log"
30           }
31         ]
32       };
33       
34       log4js.configure(config, {
35         cwd: '/absolute/path/to'
36       });
37       return appenderOptions;
38     },
39     'should be passed to appenders during configuration': function(options) {
40       assert.equal(options.cwd, '/absolute/path/to');
41     }
42   },
43
44   'file appender': {
45     topic: function() {
46       var fileOpened,
47       fileAppender = sandbox.require(
48         '../lib/appenders/file',
49         { requires:
50           { '../streams':
51             { RollingFileStream: 
52               function(file) {
53                 fileOpened = file;
54                 return {
55                   on: function() {},
56                   end: function() {}
57                 };
58               }
59             }
60           }
61         }
62       );
63       fileAppender.configure(
64         { 
65           filename: "whatever.log", 
66           maxLogSize: 10 
67         }, 
68         { cwd: '/absolute/path/to' }
69       );
70       return fileOpened;
71     },
72     'should prepend options.cwd to config.filename': function(fileOpened) {
73       var expected = path.sep + path.join("absolute", "path", "to", "whatever.log");
74       assert.equal(fileOpened, expected);
75     }
76   },
77 }).export(module);