testable-utils
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -5,2 +5,3 @@ var _ = require('lodash'); | ||
var util = require('util'); | ||
var fs = require('fs'); | ||
@@ -10,12 +11,11 @@ var AgentKey = process.env.TESTABLE_KEY; | ||
var DataTable = function(executionId, dataStore, info, log) { | ||
var DataTable = function(executionId, name, info, log) { | ||
this.executionId = executionId; | ||
this.details = dataStore; | ||
this.headers = dataStore.headers && dataStore.headers.length > 0 ? Baby.parse(dataStore.headers).data[0] : []; | ||
this.name = name; | ||
this.info = info; | ||
this.log = log; | ||
this.results = Baby.parseFiles(dataStore.name, { header: true, skipEmptyLines: true }); | ||
this.results = Baby.parseFiles(name, { header: true, skipEmptyLines: true }); | ||
if (this.results.errors && this.results.errors.length > 0) { | ||
var msg = "Errors occurred parsing " + dataStore.name + ": " + util.inspect(this.results.errors); | ||
var msg = "Errors occurred parsing " + name + ": " + util.inspect(this.results.errors); | ||
if (this.results.data.length > 0) | ||
@@ -53,3 +53,5 @@ console.log(msg); | ||
var path = "/rows/iterators/executions." + this.executionId + "/by-index?wrap=" + options.wrap + "&rows=" + options.rows; | ||
var nameForIterator = this.name.split(".").join("").split("/").join(""); | ||
var path = "/rows/iterators/executions." + this.executionId + "." + nameForIterator + "/by-index?wrap=" + options.wrap + | ||
"&rows=" + options.rows + "&length=" + this.data.length; | ||
return this._getRows(path); | ||
@@ -61,3 +63,3 @@ }; | ||
return new Promise(function(resolve, reject) { | ||
var url = BaseUrl + "/data-stores/" + self.details.id + path; | ||
var url = BaseUrl + path; | ||
url += (path.indexOf('?') !== -1 ? '&' : '?') + "key=" + AgentKey; | ||
@@ -95,3 +97,2 @@ request({ url: url }, function (error, response, body) { | ||
var executionId = info.execution.id; | ||
var dataStores = info.dataStores; | ||
@@ -105,9 +106,5 @@ return { | ||
throw new Error('Expected a .csv file'); | ||
var ds = _.find(dataStores, function(dataStore) { | ||
return dataStore.name === name; | ||
}); | ||
if (_.isObject(ds)) | ||
table = new DataTable(info.chunk.id < 0 ? info.chunk.id : executionId, ds, info, log) | ||
else | ||
if (!fs.existsSync(name)) | ||
throw new Error('Could not find ' + name + '. Please upload.'); | ||
table = new DataTable(info.chunk.id < 0 ? info.chunk.id : executionId, name, info, log) | ||
tables[name] = table; | ||
@@ -114,0 +111,0 @@ } |
{ | ||
"name": "testable-utils", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Utilities for Testable scripts", | ||
@@ -5,0 +5,0 @@ "author": "Avi Stramer", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24090
438
8