<commit_before>var chai = require('chai');
var muk = require('muk');
var expect = chai.expect;
var fs = require('fs');
var path = require('path');
var mkdirp = require('mkdirp');
var log = require('../');
var utils = require('../lib/utils');

describe('base', function () {
  describe('case', function () {
    before(function () {
      muk(mkdirp, 'sync', function (){});
      muk(fs, 'createWriteStream', function (path) {
        return {
          write: function (content) {
            console.log('muk');
            return {
              content: content,
              path: path
            };
          }
        };
      });
      muk(utils, 'getIP', function () {
        return '192.168.999.999';
      });
      muk(Date, 'now', function () {
        return 1393810654681;
      });
    });
    after(function () {
      muk.restore();
    });
    it('1', function () {
      var Logger = log.Logger;
      var dir = path.join(__dirname, '../lib/log/production.log');
      var content = {
        "@timestamp":"2014-03-03T09:37:34+08:00",
        "@source": "192.168.999.999",
        "@fields": {
          "fromtype": "myApp",
          "totype": "25",
          "interface": "/interface",
          "param": "foo=bar&abc=baz"
        },
      };
      var result = Logger().to(25).interface('/interface').param({
        foo: 'bar',
        abc: 'baz'
      }).done();
      expect(result.path).to.be.deep.equal(dir);
      expect(JSON.parse(result.content)).to.be.deep.equal(content);
    });
  });
});
<commit_msg>update test<commit_after>var chai = require('chai');
var muk = require('muk');
var expect = chai.expect;
var fs = require('fs');
var path = require('path');
var mkdirp = require('mkdirp');
var log = require('../');
var utils = require('../lib/utils');

describe('base', function () {
  describe('case', function () {
    before(function () {
      muk(mkdirp, 'sync', function (){});
      muk(fs, 'createWriteStream', function (path) {
        return {
          write: function (content) {
            console.log('muk');
            return {
              content: content,
              path: path
            };
          }
        };
      });
      muk(utils, 'getIP', function () {
        return '192.168.999.999';
      });
      muk(Date, 'now', function () {
        return 1393810654681;
      });
    });
    after(function () {
      muk.restore();
    });
    it('mini', function () {
      var Logger = log.Logger;
      var dir = path.join(__dirname, '../lib/log/production.log');
      var content = {
        "@timestamp":"2014-03-03T09:37:34+08:00",
        "@source": "192.168.999.999",
        "@fields": {
          "fromtype": "myApp",
          "totype": "myApp"
        },
      };
      var result = Logger().done();
      expect(result.path).to.be.deep.equal(dir);
      expect(JSON.parse(result.content)).to.be.deep.equal(content);
    });
    it('with to, interface, param', function () {
      var Logger = log.Logger;
      var dir = path.join(__dirname, '../lib/log/production.log');
      var content = {
        "@timestamp":"2014-03-03T09:37:34+08:00",
        "@source": "192.168.999.999",
        "@fields": {
          "fromtype": "myApp",
          "totype": "25",
          "interface": "/interface",
          "param": "foo=bar&abc=baz"
        },
      };
      var result = Logger().to(25).interface('/interface').param({
        foo: 'bar',
        abc: 'baz'
      }).done();
      expect(result.path).to.be.deep.equal(dir);
      expect(JSON.parse(result.content)).to.be.deep.equal(content);
    });
    it('with string param', function () {
      var Logger = log.Logger;
      var dir = path.join(__dirname, '../lib/log/production.log');
      var content = {
        "@timestamp":"2014-03-03T09:37:34+08:00",
        "@source": "192.168.999.999",
        "@fields": {
          "fromtype": "myApp",
          "totype": "25",
          "interface": "/interface",
          "param": "check: it out"
        },
      };
      var result = Logger().to(25).interface('/interface').param('check: it out').done();
      expect(result.path).to.be.deep.equal(dir);
      expect(JSON.parse(result.content)).to.be.deep.equal(content);
    });
    it('with result', function () {
      var Logger = log.Logger;
      var dir = path.join(__dirname, '../lib/log/production.log');
      var content = {
        "@timestamp":"2014-03-03T09:37:34+08:00",
        "@source": "192.168.999.999",
        "@fields": {
          "fromtype": "myApp",
          "totype": "25",
          "interface": "/interface",
          "param": "foo=bar&abc=baz",
          "result": "{\"foo\":\"bar\"}"
        },
      };
      var result = Logger().to(25).interface('/interface').param({
        foo: 'bar',
        abc: 'baz'
      }).result({foo: "bar"}).done();
      expect(result.path).to.be.deep.equal(dir);
      expect(JSON.parse(result.content)).to.be.deep.equal(content);
    });
  });
});

{'fraction_non_alphanumeric': 0.20274359491628, 'fraction_numerical': 0.04377647770829131, 'mean_word_length': 2.0623841877702285, 'pattern_counts': {'":': 35, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6560394', 'n_tokens_mistral': 1700, 'n_tokens_neox': 1576, 'n_words': 281}