<commit_before>'use strict';

/* global describe, it */

var assert = require('assert');
var exec = require('child_process').exec;
var fsx = require('fs-extra');
var path = require('path');
var shortid = require('shortid');
var _ = require('lodash');

var buildRpm = require('../');

describe('rpm builder', function() {

  describe('rpm init', function() {

    it('should throw an error if options object is missing', function() {
      assert.throws(buildRpm, TypeError);
    });

    it('should throw an error if options is not an object', function() {
      assert.throws(function() {
        buildRpm('');
      }, TypeError);
    });

    it('should throw an error if callback is missing', function() {
      assert.throws(function() {
        buildRpm({});
      }, TypeError);
    });

    it('should throw an error if callback is not a function', function() {
      assert.throws(function() {
        buildRpm({}, '');
      }, TypeError);
    });

  });

  describe('rpm output', function() {

    it('should keep the temp folder when `keepTemp: true`', function(done) {
      var options = {
        tempDir: 'rpm-builder-test-tmp-' + shortid.generate(),<commit_msg>Fix issue with the temp folders when testing<commit_after>'use strict';

/* global describe, it, after */

var assert = require('assert');
var exec = require('child_process').exec;
var fsx = require('fs-extra');
var globby = require('globby');
var path = require('path');
var shortid = require('shortid');
var _ = require('lodash');

var buildRpm = require('../');

describe('rpm builder', function() {

  describe('rpm init', function() {

    it('should throw an error if options object is missing', function() {
      assert.throws(buildRpm, TypeError);
    });

    it('should throw an error if options is not an object', function() {
      assert.throws(function() {
        buildRpm('');
      }, TypeError);
    });

    it('should throw an error if callback is missing', function() {
      assert.throws(function() {
        buildRpm({});
      }, TypeError);
    });

    it('should throw an error if callback is not a function', function() {
      assert.throws(function() {
        buildRpm({}, '');
      }, TypeError);
    });

  });

  describe('rpm output', function() {

    after(function() {
      // remove temp folder left overs
      _.forEach(globby.sync('./rpm-builder-test-*'), function(dir) {
        if (fsx.existsSync(dir)) {
          fsx.removeSync(dir);
        }
      });
    });

    it('should keep the temp folder when `keepTemp: true`', function(done) {
      var options = {
        tempDir: 'rpm-builder-test-tmp-' + shortid.generate(),
{'fraction_non_alphanumeric': 0.16553544494720965, 'fraction_numerical': 0.0, 'mean_word_length': 3.025796661608498, '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': '597909', 'n_tokens_mistral': 787, 'n_tokens_neox': 753, 'n_words': 221}