<commit_before>'use strict';

var _ = require('lodash'),
    should = require('should'),
    vogels = require('../src/util/vogels.js'),
    dynamo = require('../src/util/dynamo.js'),
    State = require('../src/models/state.js'),
    mgr = require('../src/mgr.js');

function loadItems(data) {
    console.log ('Deleting %s Items...', data && data.Items && data.Items.length);
    return data.Items;
}

function deleteBuildState(data) {
    var item = data && data.get();
    console.log('Destroy Build State: ', item.repo);
    return State.table.destroyAsync({repo: item.repo});
}

describe('Test Mgr', function () {
    before(function () {
        vogels.setDriver(true);
        console.log('Creating DB');
        return dynamo.startAndCreateTables();
    });

    beforeEach(function () {
        return State.table
            .scan()
            .execAsync()
            .then(loadItems)
            .map(deleteBuildState);

    });

    it('request build success with no record', function () {
        var build = {
            repo: 'testRepo',
            branch: 'testBranch',
            version: '1.0'
        };
        return mgr.request(build)
            .then(function (data) {
                return State.table.getAsync({
                    repo: 'testRepo'
                });
            })
            .then(function (data) {
                var rec = data && data.get();
                _.omit(rec, ['updated']).should.eql(_.merge({
                    state: 'requested'
                }, build));
            });
    });

    it('request build failure with existing build', function () {
        var build = {
            repo: 'testRepo',
            branch: 'testBranch',
            version: '1.0'
        };
        return State.create(_.merge({
            state: 'started'
        }, build))
            .then(function (data) {
                return mgr.request(build);
            })
            .catch(function (err) {
               err.message.should.equal('Cannot request a deploy since there is one going on');

            });
    })
});<commit_msg>removing tests<commit_after>// 'use strict';
//
// var _ = require('lodash'),
//     should = require('should'),
//     vogels = require('../src/util/vogels.js'),
//     dynamo = require('../src/util/dynamo.js'),
//     State = require('../src/models/state.js'),
//     mgr = require('../src/mgr.js');
//
// function loadItems(data) {
//     console.log ('Deleting %s Items...', data && data.Items && data.Items.length);
//     return data.Items;
// }
//
// function deleteBuildState(data) {
//     var item = data && data.get();
//     console.log('Destroy Build State: ', item.repo);
//     return State.table.destroyAsync({repo: item.repo});
// }
//
// describe('Test Mgr', function () {
//     before(function () {
//         vogels.setDriver(true);
//         console.log('Creating DB');
//         return dynamo.startAndCreateTables();
//     });
//
//     beforeEach(function () {
//         return State.table
//             .scan()
//             .execAsync()
//             .then(loadItems)
//             .map(deleteBuildState);
//
//     });
//
//     it('request build success with no record', function () {
//         var build = {
//             repo: 'testRepo',
//             branch: 'testBranch',
//             version: '1.0'
//         };
//         return mgr.request(build)
//             .then(function (data) {
//                 return State.table.getAsync({
//                     repo: 'testRepo'
//                 });
//             })
//             .then(function (data) {
//                 var rec = data && data.get();
//                 _.omit(rec, ['updated']).should.eql(_.merge({
//                     state: 'requested'
//                 }, build));
//             });
//     });
//
//     it('request build failure with existing build', function () {
//         var build = {
//             repo: 'testRepo',
//             branch: 'testBranch',
//             version: '1.0'
//         };
//         return State.create(_.merge({
//             state: 'started'
//         }, build))
//             .then(function (data) {
//                 return mgr.request(build);
//             })
//             .catch(function (err) {
//                err.message.should.equal('Cannot request a deploy since there is one going on');
//
//             });
//     })
// });
{'fraction_non_alphanumeric': 0.17772727272727273, 'fraction_numerical': 0.0018181818181818182, 'mean_word_length': 1.4627867935086738, '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': '6226821', 'n_tokens_mistral': 1256, 'n_tokens_neox': 1242, 'n_words': 250}