UNPKG

@testim/testim-cli

Version:

Command line interface for running Testing on you CI

42 lines (35 loc) 1.36 kB
var Promise = require('promise'); var TestRun = require('./testRunHandler.js'); var firebaseConnection = require('./testimFirebaseConnection.js'); function createExecutionObject(executionId, testIdsList, labels){ var executionData = { "labels": labels, "testList" : testIdsList, "startTime" : Date.now() }; return firebaseConnection.saveExecution(executionId, executionData); } var ExecutionQueue = function(executionId, testList, labels){ this.executionId = executionId; var testIdsList = testList.map(function(testInfo){ return testInfo.testId; }); createExecutionObject(executionId, testIdsList, labels); this._waitingTests = testList.map(function(testInfo){ return new TestRun(executionId, testInfo.testId, testInfo.name); }); this._executionId = executionId; console.log("batch execution " + executionId + " was created"); }; ExecutionQueue.prototype.getNext = function(){ return new Promise(function(resolve){ var nextTestRunHandler = this._waitingTests.shift(); if(nextTestRunHandler) { resolve(nextTestRunHandler); } }.bind(this)); }; ExecutionQueue.prototype.close = function(){ return firebaseConnection.saveExecutionEnd(this.executionId); }; module.exports = ExecutionQueue;