<commit_before>require('colors');

var assert = require('assert');
// var request = require('request');
// var http = require('http');
var path = require('path');
var Args = require('hemsl');
var hiproxy = require('../../src/index');
var Proxy = hiproxy.Server;
var request = require('../request');
var pluginManager = require('../../src/plugin');
var routes = hiproxy.router;
var directives = require('../../src/directives');

describe('# plugin'.bold.green, function () {
  var proxyServer;
  var args = new Args();
  before(function () {
    // testServer.listen(6789);

    // 加载插件
    pluginManager.loadPlugins(path.join(__dirname, 'hiproxy-plugin-example/index.js'), args);

    proxyServer = global.hiproxyServer = new Proxy(8848, 8849);
    // proxyServer.addRewriteFile(path.join(__dirname, 'rewrite'));
    proxyServer.start();
  });

  after(function () {
    // testServer.close();
    proxyServer.stop();
  });

  describe('# get installed plugin', function () {
    it('# should get all installed plugin', function () {
      var promise = pluginManager.getInstalledPlugins(__dirname);

      return promise.then(function (plugins) {
        var plg1 = path.join(__dirname, 'hiproxy-plugin-example');
        var plg2 = path.join(__dirname, 'hiproxy-plugin-demo');
        console.log('plugins: ', plugins);
        assert.equal(plugins.length, 2);
        assert.notEqual(plugins.indexOf(plg1), -1);
        assert.notEqual(plugins.indexOf(plg2), -1);<commit_msg>回退test版本<commit_after>require('colors');

var assert = require('assert');
// var request = require('request');
// var http = require('http');
var path = require('path');
var Args = require('hemsl');
var hiproxy = require('../../src/index');
var Proxy = hiproxy.Server;
var request = require('../request');
var pluginManager = require('../../src/plugin');
var routes = hiproxy.router;
var directives = require('../../src/directives');

describe('# plugin'.bold.green, function () {
  var proxyServer;
  var args = new Args();
  before(function () {
    // testServer.listen(6789);

    // 加载插件
    pluginManager.loadPlugins(path.join(__dirname, 'hiproxy-plugin-example/index.js'), args);

    proxyServer = global.hiproxyServer = new Proxy(8848, 8849);
    // proxyServer.addRewriteFile(path.join(__dirname, 'rewrite'));
    proxyServer.start();
  });

  after(function () {
    // testServer.close();
    proxyServer.stop();
  });

  describe('# get installed plugin', function () {
    it('# should get all installed plugin', function () {
      var promise = pluginManager.getInstalledPlugins(__dirname);

      return promise.then(function (plugins) {
        var plg1 = path.join(__dirname, 'hiproxy-plugin-example');
        var plg2 = path.join(__dirname, 'hiproxy-plugin-demo');

        assert.equal(plugins.length, 2);
        assert.notEqual(plugins.indexOf(plg1), -1);
        assert.notEqual(plugins.indexOf(plg2), -1);
{'fraction_non_alphanumeric': 0.17531797868683396, 'fraction_numerical': 0.013062908215881746, 'mean_word_length': 3.6634615384615383, 'pattern_counts': {'":': 0, '<': 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': '4982847', 'n_tokens_mistral': 907, 'n_tokens_neox': 879, 'n_words': 185}