/**
 * Created by Tony on 2017/3/21.
 */
var test = require('tape');
var counter = require('../../../public/counter/counter');
var mongoose = require('mongoose');

test('test counter\'s usage 0:', function(t) {
    var promise = counter.counterDAO.getCurrentID(counter.moduleName.report,function(result, err) {
        console.log('callback result 0: ' + result.sequence_value);
    });
    if (promise) {
        promise.then(function(rst){
            console.log('promise result 0: ' + rst.sequence_value);
        });
    }
    t.pass('just pass');
    t.end();
})

test('test counter\'s usage 1:', function(t) {
    var promise = counter.counterDAO.getCurrentID(counter.moduleName.report, null);
    if (promise) {
        promise.then(function(rst){
            console.log('promise result 1: ' + rst.sequence_value);
        });
    }
    t.pass('just pass');
    t.end();
})

test('test counter\'s usage 2:', function(t) {
    counter.counterDAO.getIDAfterCount(counter.moduleName.report, 1, function(err, result){
        console.log('result 2: ' + result.sequence_value);
        t.equal(result.sequence_value, 1);
        t.end();
    });
})

test('finish', function (t) {
    mongoose.disconnect();
    t.pass('closing db connection');
    t.end();
});
