<commit_before>const assert = require('assert');
const axios = require('axios');

async function runTest(f) {
    const assertObj = {
        equal: assert.deepStrictEqual,
        true: assert.ok
    };

    var requestObj = axios.create({
        baseURL: process.argv[2],
        validateStatus: function () { return true; }
    });

    try {
        const token = await logIn(assertObj, requestObj);

        requestObj = axios.create({
            baseURL: process.argv[2],
            validateStatus: function () { return true; },
            headers: { 'X-Authentication': token }
        });

        await f(assertObj, requestObj);

        await logOut(assertObj, requestObj, token);
    } catch (e) {
        if (e instanceof assert.AssertionError) {
            console.log(e.toString());
            console.log('\nExpected:');
            console.log(e.expected);
            console.log('\nGot:');
            console.log(e.actual);
            process.exit(2);
        } else {
            console.log(e.toString());
            process.exit(1);
        }
    }

    process.exit(0);
}

async function logIn(assert, req) {
    //Try to login with valid username and password
    var res = await req({
        url: '/sessions',
        method: 'post',
        data: {
            username: 'admin',
            password: '<PASSWORD>'
        }
    });

    assert.equal(res.status, 201, 'LOGIN: Status not valid');
    assert.equal(res.data.username, 'admin', 'LOGIN: Username should be admin');
    assert.equal(res.data.token.length, 86, 'LOGIN: Token length fail');

    return res.data.token;
}

async function logOut(assert, req, token) {
    //Try to logout check if this works
    var res = await req({
        url: '/sessions/' + token,
        method: 'delete'
    });

    assert.equal(res.status, 204, 'LOGOUT: Answer should be successfull but empty');
}

module.exports = runTest;<commit_msg>Added debug output for travis<commit_after>const assert = require('assert');
const axios = require('axios');

async function runTest(f) {
    const assertObj = {
        equal: assert.deepStrictEqual,
        true: assert.ok
    };

    var requestObj = axios.create({
        baseURL: process.argv[2],
        validateStatus: function () { return true; }
    });

    try {
        const token = await logIn(assertObj, requestObj);

        requestObj = axios.create({
            baseURL: process.argv[2],
            validateStatus: function () { return true; },
            headers: { 'X-Authentication': token }
        });

        await f(assertObj, requestObj);

        await logOut(assertObj, requestObj, token);
    } catch (e) {
        if (e instanceof assert.AssertionError) {
            console.log(e.toString());
            console.log('\nExpected:');
            console.log(e.expected);
            console.log('\nGot:');
            console.log(e.actual);
            process.exit(2);
        } else {
            console.log(e.toString());
            process.exit(1);
        }
    }

    process.exit(0);
}

async function logIn(assert, req) {
    //Try to login with valid username and password
    var res = await req({
        url: '/sessions',
        method: 'post',
        data: {
            username: 'admin',
            password: '<PASSWORD>'
        }
    });

    console.log(res);

    assert.equal(res.status, 201, 'LOGIN: Status not valid');
    assert.equal(res.data.username, 'admin', 'LOGIN: Username should be admin');
    assert.equal(res.data.token.length, 86, 'LOGIN: Token length fail');

    return res.data.token;
}

async function logOut(assert, req, token) {
    //Try to logout check if this works
    var res = await req({
        url: '/sessions/' + token,
        method: 'delete'
    });

    assert.equal(res.status, 204, 'LOGOUT: Answer should be successfull but empty');
}

module.exports = runTest;
{'fraction_non_alphanumeric': 0.13508636246455272, 'fraction_numerical': 0.006702758442897654, 'mean_word_length': 2.129032258064516, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7450828', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1122, 'n_words': 288}