node-webplay
Version:
A nodejs streaming server implementation
152 lines (110 loc) • 3.44 kB
JavaScript
;
var _chai = require("chai");
var _chai2 = _interopRequireDefault(_chai);
var _procman = require("../../processor/procman.js");
var _procman2 = _interopRequireDefault(_procman);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var expect = _chai2.default.expect;
function tval(name, def) {
if (null == process.env[name]) {
return def;
}
return process.env[name];
}
function check(done, f) {
try {
f();
done();
} catch (e) {
done(e);
}
}
function test_proc_man(require_string, owner) {
var p = new _procman2.default({ statusman: require_string });
var id = "";
//let owner = "uploader";
var name = "TEST";
it("reserve name", function (done) {
p.reserve_name(owner, name).then(function (idx) {
check(done, function () {
expect(idx).to.be.a("string");
id = idx;
console.log("-----", id, "------");
});
}, function (err) {
done(err);
});
});
it("queue job", function (done) {
var file = tval("TESTMEDIAFILE", "./src/processor/test/MEDIA1.MP4");
p.queue_job(owner, id, file).then(function () {
check(done, function () {
expect(id).to.be.a("string");
expect(id).to.be.match(/\d{10,12}_TEST/);
});
}, function (err) {
return done(err);
});
});
it("list", function (done) {
p.list(owner).then(function (list) {
check(done, function () {
var r = {
assets: [{
owner: owner,
id: id
}]
};
expect(list).to.be.deep.equal(r);
});
}, function (err) {
done(err);
});
});
it("status", function (done) {
var r = {
status: "ok",
name: "TEST",
id: id,
datetime: null,
creationtime: null,
processing: null,
owner: owner,
hls3: "STATIC/main.m3u8",
dash: "STATIC/index.mpd",
thumb: ["img001.jpg", "img002.jpg"],
previus: ["reserved", "analized", "encoded"],
hls4: null,
playready: null,
widevine: null
};
p.status(owner, id).then(function (status) {
status.datetime = null;
status.creationtime = null;
status.processing = null;
check(done, function () {
expect(status).to.be.deep.equal(r);
});
}, function (err) {
done(err);
});
});
}
describe("PROCESS MANAGER", function () {
it("set up correctly", function (done) {
expect(_procman2.default).to.be.a("function");
var p = new _procman2.default();
expect(p).to.be.a("object");
check(done, function () {
//console.log(p.get_full_name());
//console.log(p.get_target_dir());
});
});
describe("Fake StatMan", function () {
test_proc_man("./test/stateman.js", "uploader");
});
describe("Fs StatMan", function () {
test_proc_man("./statmanfs.js", "statman");
});
});
//# sourceMappingURL=procman.test.js.map