How to use testConstants method in wpt

Best JavaScript code snippet using wpt

L0.ts

Source:L0.ts Github

copy

Full Screen

1import * as path from 'path';2import * as assert from 'assert';3import * as ttm from 'azure-pipelines-task-lib/mock-test';4import * as constants from '../constants';5import * as testConstants from './TestConstants';6import * as tl from 'azure-pipelines-task-lib';7describe('VsTestPlatformToolInstaller Suite', function() {8 this.timeout(10000);9 if (!tl.osType().match(/^Win/)) {10 return;11 }12 before((done) => {13 done();14 });15 beforeEach((done) => {16 // Clear all inputs and other environment variables17 delete process.env[constants.vsTestToolsInstallerInstalledToolLocation];18 delete process.env[constants.versionSelector];19 delete process.env[constants.testPlatformVersion];20 delete process.env[constants.downloadPath];21 delete process.env[testConstants.expectedTestPlatformVersion];22 delete process.env[testConstants.findLocalToolFirstCallReturnValue];23 delete process.env[testConstants.findLocalToolSecondCallReturnValue];24 delete process.env[testConstants.listPackagesReturnCode];25 delete process.env[testConstants.listPackagesOutput];26 delete process.env[constants.username];27 delete process.env[constants.password];28 delete process.env[testConstants.feedId];29 delete process.env[constants.packageFeedSelector];30 delete process.env[constants.customFeed];31 delete process.env[testConstants.packageSource];32 delete process.env[testConstants.configFile];33 process.env[constants.packageFeedSelector] = constants.nugetOrg;34 process.env[testConstants.packageSource] = constants.defaultPackageSource;35 process.env[testConstants.writeNugetConfigReturnCode] = '0';36 process.env[constants.agentTempDirectory] = 'temp';37 process.env[constants.downloadPath] = `${process.env[constants.agentTempDirectory]}\\VsTest`;38 done();39 });40 after(function () {41 // add code for cleanup if any42 });43 // *************************************************** Nuget Org Tests ******************************************************44 it('Get latest pre-release version cache hit', (done: MochaDone) => {45 // Setup the mock runner46 const tp = path.join(__dirname, 'TestSetup.js');47 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);48 // Set the inputs49 process.env[constants.versionSelector] = 'latestPreRelease';50 process.env[constants.testPlatformVersion] = '';51 process.env[testConstants.expectedTestPlatformVersion] = '15.6.0-preview-20171108-02';52 process.env[testConstants.findLocalToolFirstCallReturnValue] = `VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}`;53 process.env[testConstants.listPackagesReturnCode] = '0';54 // Start the run55 tr.run();56 // Asserts57 assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');58 assert(tr.succeeded, `Task should have succeeded`);59 assert(tr.stdOutContained(`LookingForLatestPreReleaseVersion`), `Should have looked for latest pre-release version.`);60 assert(tr.stdOutContained(`Found the latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have found latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}`);61 assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);62 assert(tr.stdOutContained(`Cache hit for ${process.env[testConstants.expectedTestPlatformVersion]}`), `Expected a cache hit.`);63 assert(tr.stdOutContained(`Set variable VsTestToolsInstallerInstalledToolLocation value to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have set variable to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`);64 assert(tr.stdOutContained('InstallationSuccessful'));65 done();66 });67 it('Get latest pre-release version cache miss and download success', (done: MochaDone) => {68 // Setup the mock runner69 const tp = path.join(__dirname, 'TestSetup.js');70 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);71 // Set the inputs72 process.env[constants.versionSelector] = 'latestPreRelease';73 process.env[constants.testPlatformVersion] = '';74 process.env[testConstants.expectedTestPlatformVersion] = '15.6.0-preview-20171108-02';75 process.env[testConstants.listPackagesReturnCode] = '0';76 process.env[testConstants.downloadPackageReturnCode] = '0';77 // Start the run78 tr.run();79 // Asserts80 assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');81 assert(tr.succeeded, `Task should have succeeded`);82 assert(tr.stdOutContained(`LookingForLatestPreReleaseVersion`), `Should have looked for latest pre-release version.`);83 assert(tr.stdOutContained(`Found the latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have found latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}`);84 assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);85 assert(tr.stdOutContained(`Could not find Microsoft.TestPlatform.${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache. Fetching it from nuget.`), `Should have encountered a cache miss for ${process.env[testConstants.expectedTestPlatformVersion]}.`);86 assert(tr.stdOutContained(`Downloading Test Platform version ${process.env[testConstants.expectedTestPlatformVersion]} from ${process.env[testConstants.packageSource]} to ${process.env[constants.downloadPath]}.`), `Should have attempted download of version ${process.env[testConstants.expectedTestPlatformVersion]}`);87 assert(tr.stdOutContained(`Caching the downloaded folder temp\\VsTest\\${constants.packageId}.${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have cached ${process.env[testConstants.expectedTestPlatformVersion]}`);88 assert(tr.stdOutContained(`Set variable VsTestToolsInstallerInstalledToolLocation value to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have set variable to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`);89 assert(tr.stdOutContained('InstallationSuccessful'));90 done();91 });92 it('Get latest pre-release version listing failed but a stable version found in cache', (done: MochaDone) => {93 // Setup the mock runner94 const tp = path.join(__dirname, 'TestSetup.js');95 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);96 // Set the inputs97 process.env[constants.versionSelector] = 'latestPreRelease';98 process.env[constants.testPlatformVersion] = '';99 process.env[testConstants.expectedTestPlatformVersion] = 'x';100 process.env[testConstants.listPackagesReturnCode] = '1';101 process.env[testConstants.downloadPackageReturnCode] = '0';102 process.env[testConstants.findLocalToolFirstCallReturnValue] = `VsTest\\15.6.0`;103 // Start the run104 tr.run();105 // Asserts106 assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');107 assert(tr.succeeded, `Task should have succeeded`);108 assert(tr.stdOutContained(`LookingForLatestPreReleaseVersion`), `Should have looked for latest pre-release version.`);109 assert(tr.stdOutContained(`FailedToListAvailablePackagesFromNuget`), `Listing packages should have failed.`);110 assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);111 assert(tr.stdOutContained(`Cache hit for ${process.env[testConstants.expectedTestPlatformVersion]}`), `Should have been a cache hit for ${process.env[testConstants.expectedTestPlatformVersion]}`);112 assert(tr.stdOutContained(`Set variable VsTestToolsInstallerInstalledToolLocation value to ${process.env[testConstants.findLocalToolFirstCallReturnValue]}.`), `Should have set variable to ${process.env[testConstants.findLocalToolFirstCallReturnValue]}.`);113 assert(tr.stdOutContained('InstallationSuccessful'));114 done();115 });116 it('Get latest pre-release version listing failed but no stable version found in cache', (done: MochaDone) => {117 // Setup the mock runner118 const tp = path.join(__dirname, 'TestSetup.js');119 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);120 // Set the inputs121 process.env[constants.versionSelector] = 'latestPreRelease';122 process.env[constants.testPlatformVersion] = '';123 process.env[testConstants.listPackagesReturnCode] = '1';124 process.env[testConstants.downloadPackageReturnCode] = '0';125 process.env[testConstants.expectedTestPlatformVersion] = 'x';126 // Start the run127 tr.run();128 // Asserts129 assert(tr.stderr.length !== 0 || tr.errorIssues.length, 'should have written to stderr');130 assert(tr.failed, `Task should have failed`);131 assert(tr.stdOutContained(`LookingForLatestPreReleaseVersion`), `Should have looked for latest pre-release version.`);132 assert(tr.stdOutContained(`FailedToListAvailablePackagesFromNuget`), `Listing packages should have failed.`);133 assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);134 assert(tr.stdOutContained(`Cache miss for ${process.env[testConstants.expectedTestPlatformVersion]}`), `Should have been a cache miss for ${process.env[testConstants.expectedTestPlatformVersion]}`);135 assert(tr.stdOutContained('NoPackageFoundInCache'), `Should warn no stable package found in cache`);136 assert(tr.stdOutContained('FailedToAcquireTestPlatform'), `Should fail with failed to acquire test platform`);137 done();138 });139 it('Get latest pre-release version cache miss and download failed but fallback cache hit', (done: MochaDone) => {140 // Setup the mock runner141 const tp = path.join(__dirname, 'TestSetup.js');142 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);143 // Set the inputs144 process.env[constants.versionSelector] = 'latestPreRelease';145 process.env[constants.testPlatformVersion] = '';146 process.env[testConstants.expectedTestPlatformVersion] = '15.6.0-preview-20171108-02';147 process.env[testConstants.listPackagesReturnCode] = '0';148 process.env[testConstants.downloadPackageReturnCode] = '1';149 process.env[testConstants.findLocalToolSecondCallReturnValue] = `VsTest\\15.6.0`;150 // Start the run151 tr.run();152 // Asserts153 assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');154 assert(tr.succeeded, `Task should have succeeded`);155 assert(tr.stdOutContained(`LookingForLatestPreReleaseVersion`), `Should have looked for latest pre-release version.`);156 assert(tr.stdOutContained(`Found the latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have found latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}`);157 assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);158 assert(tr.stdOutContained(`Could not find Microsoft.TestPlatform.${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache. Fetching it from nuget.`), `Should have encountered a cache miss for ${process.env[testConstants.expectedTestPlatformVersion]}.`);159 assert(tr.stdOutContained(`Downloading Test Platform version ${process.env[testConstants.expectedTestPlatformVersion]} from ${process.env[testConstants.packageSource]} to ${process.env[constants.downloadPath]}.`), `Should have attempted download of version ${process.env[testConstants.expectedTestPlatformVersion]}`);160 assert(tr.stdOutContained(`TestPlatformDownloadFailed`), `Download should have failed`);161 assert(tr.stdOutContained(`Set variable VsTestToolsInstallerInstalledToolLocation value to ${process.env[testConstants.findLocalToolSecondCallReturnValue]}.`), `Should have set variable to ${process.env[testConstants.findLocalToolSecondCallReturnValue]}.`);162 assert(tr.stdOutContained('InstallationSuccessful'));163 done();164 });165 it('Get latest pre-release version cache miss and download failed and fallback cache miss', (done: MochaDone) => {166 // Setup the mock runner167 const tp = path.join(__dirname, 'TestSetup.js');168 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);169 // Set the inputs170 process.env[constants.versionSelector] = 'latestPreRelease';171 process.env[constants.testPlatformVersion] = '';172 process.env[testConstants.expectedTestPlatformVersion] = '15.6.0-preview-20171108-02';173 process.env[testConstants.listPackagesReturnCode] = '0';174 process.env[testConstants.downloadPackageReturnCode] = '1';175 // Start the run176 tr.run();177 // Asserts178 assert(tr.stderr.length !== 0 || tr.errorIssues.length, 'should not have written to stderr');179 assert(tr.failed, `Task should have failed`);180 assert(tr.stdOutContained(`LookingForLatestPreReleaseVersion`), `Should have looked for latest pre-release version.`);181 assert(tr.stdOutContained(`Found the latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have found latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}`);182 assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);183 assert(tr.stdOutContained(`Could not find Microsoft.TestPlatform.${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache. Fetching it from nuget.`), `Should have encountered a cache miss for ${process.env[testConstants.expectedTestPlatformVersion]}.`);184 assert(tr.stdOutContained(`Downloading Test Platform version ${process.env[testConstants.expectedTestPlatformVersion]} from ${process.env[testConstants.packageSource]} to ${process.env[constants.downloadPath]}.`), `Should have attempted download of version ${process.env[testConstants.expectedTestPlatformVersion]}`);185 assert(tr.stdOutContained(`TestPlatformDownloadFailed`), `Download should have failed`);186 process.env[testConstants.expectedTestPlatformVersion] = 'x';187 assert(tr.stdOutContained(`Cache miss for ${process.env[testConstants.expectedTestPlatformVersion]}`), `Should have been a cache miss for ${process.env[testConstants.expectedTestPlatformVersion]}`);188 assert(tr.stdOutContained('NoPackageFoundInCache'), `Should warn no stable package found in cache`);189 assert(tr.stdOutContained('FailedToAcquireTestPlatform'), `Should fail with failed to acquire test platform`);190 done();191 });192 it('Get latest stable version cache hit', (done: MochaDone) => {193 // Setup the mock runner194 const tp = path.join(__dirname, 'TestSetup.js');195 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);196 // Set the inputs197 process.env[constants.versionSelector] = 'latestStable';198 process.env[constants.testPlatformVersion] = '';199 process.env[testConstants.expectedTestPlatformVersion] = '15.6.0';200 process.env[testConstants.findLocalToolFirstCallReturnValue] = `VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}`;201 process.env[testConstants.listPackagesReturnCode] = '0';202 // Start the run203 tr.run();204 // Asserts205 assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');206 assert(tr.succeeded, `Task should have succeeded`);207 assert(tr.stdOutContained(`LookingForLatestStableVersion`), `Should have looked for latest stable version.`);208 assert(tr.stdOutContained(`Found the latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have found latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}`);209 assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);210 assert(tr.stdOutContained(`Cache hit for ${process.env[testConstants.expectedTestPlatformVersion]}`), `Expected a cache hit.`);211 assert(tr.stdOutContained(`Set variable VsTestToolsInstallerInstalledToolLocation value to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have set variable to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`);212 assert(tr.stdOutContained('InstallationSuccessful'));213 done();214 });215 it('Get latest stable version listing empty and cache hit', (done: MochaDone) => {216 // Setup the mock runner217 const tp = path.join(__dirname, 'TestSetup.js');218 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);219 // Set the inputs220 process.env[constants.versionSelector] = 'latestStable';221 process.env[constants.testPlatformVersion] = '';222 process.env[testConstants.expectedTestPlatformVersion] = 'x';223 process.env[testConstants.listPackagesReturnCode] = '0';224 process.env[testConstants.findLocalToolFirstCallReturnValue] = `VsTest\\15.6.0`;225 process.env[testConstants.listPackagesOutput] = '';226 // Start the run227 tr.run();228 // Asserts229 assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');230 assert(tr.succeeded, `Task should have succeeded`);231 assert(tr.stdOutContained(`LookingForLatestStableVersion`), `Should have looked for latest stable version.`);232 assert(tr.stdOutContained(`FailedToListAvailablePackagesFromNuget`), `Listing packages should have failed.`);233 assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);234 assert(tr.stdOutContained(`Cache hit for ${process.env[testConstants.expectedTestPlatformVersion]}`), `Should have been a cache hit for ${process.env[testConstants.expectedTestPlatformVersion]}`);235 assert(tr.stdOutContained(`Set variable VsTestToolsInstallerInstalledToolLocation value to ${process.env[testConstants.findLocalToolFirstCallReturnValue]}.`), `Should have set variable to ${process.env[testConstants.findLocalToolFirstCallReturnValue]}.`);236 assert(tr.stdOutContained('InstallationSuccessful'));237 done();238 });239 it('Get specific version cache hit', (done: MochaDone) => {240 // Setup the mock runner241 const tp = path.join(__dirname, 'TestSetup.js');242 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);243 // Set the inputs244 process.env[constants.versionSelector] = 'specificVersion';245 process.env[constants.testPlatformVersion] = '15.6.0-preview-20171108-02';246 process.env[testConstants.expectedTestPlatformVersion] = '15.6.0-preview-20171108-02';247 process.env[testConstants.findLocalToolFirstCallReturnValue] = `VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}`;248 // Start the run249 tr.run();250 // Asserts251 assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');252 assert(tr.succeeded, `Task should have succeeded`);253 assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);254 assert(tr.stdOutContained(`Cache hit for ${process.env[testConstants.expectedTestPlatformVersion]}`), `Expected a cache hit.`);255 assert(tr.stdOutContained(`Set variable VsTestToolsInstallerInstalledToolLocation value to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have set variable to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`);256 assert(tr.stdOutContained('InstallationSuccessful'));257 done();258 });259 it('Get specific version cache miss and download success', (done: MochaDone) => {260 // Setup the mock runner261 const tp = path.join(__dirname, 'TestSetup.js');262 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);263 // Set the inputs264 process.env[constants.versionSelector] = 'specificVersion';265 process.env[constants.testPlatformVersion] = '15.6.0-preview-20171108-02';266 process.env[testConstants.expectedTestPlatformVersion] = '15.6.0-preview-20171108-02';267 process.env[testConstants.downloadPackageReturnCode] = '0';268 // Start the run269 tr.run();270 // Asserts271 assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');272 assert(tr.succeeded, `Task should have succeeded`);273 assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);274 assert(tr.stdOutContained(`Could not find Microsoft.TestPlatform.${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache. Fetching it from nuget.`), `Should have encountered a cache miss for ${process.env[testConstants.expectedTestPlatformVersion]}.`);275 assert(tr.stdOutContained(`Downloading Test Platform version ${process.env[testConstants.expectedTestPlatformVersion]} from ${process.env[testConstants.packageSource]} to ${process.env[constants.downloadPath]}.`), `Should have attempted download of version ${process.env[testConstants.expectedTestPlatformVersion]}`);276 assert(tr.stdOutContained(`Caching the downloaded folder temp\\VsTest\\${constants.packageId}.${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have cached ${process.env[testConstants.expectedTestPlatformVersion]}`);277 assert(tr.stdOutContained(`Set variable VsTestToolsInstallerInstalledToolLocation value to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have set variable to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`);278 assert(tr.stdOutContained('InstallationSuccessful'));279 done();280 });281 // ***************************************************** Custom Feed Tests *************************************************************282 it('Get latest pre-release version cache hit from custom feed no password', (done: MochaDone) => {283 // Setup the mock runner284 const tp = path.join(__dirname, 'TestSetup.js');285 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);286 // Set the inputs287 process.env[constants.packageFeedSelector] = constants.customFeed;288 process.env[constants.customFeed] = 'somecustomfeed';289 process.env[testConstants.packageSource] = 'somecustomfeed';290 process.env[constants.versionSelector] = 'latestPreRelease';291 process.env[constants.testPlatformVersion] = '';292 process.env[testConstants.expectedTestPlatformVersion] = '15.6.0-preview-20171108-02';293 process.env[testConstants.findLocalToolFirstCallReturnValue] = `VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}`;294 process.env[testConstants.listPackagesReturnCode] = '0';295 // Start the run296 tr.run();297 // Asserts298 assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');299 assert(tr.succeeded, `Task should have succeeded`);300 assert(tr.stdOutContained(`LookingForLatestPreReleaseVersion`), `Should have looked for latest pre-release version.`);301 assert(tr.stdOutContained(`Found the latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have found latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}`);302 assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);303 assert(tr.stdOutContained(`Cache hit for ${process.env[testConstants.expectedTestPlatformVersion]}`), `Expected a cache hit.`);304 assert(tr.stdOutContained(`Set variable VsTestToolsInstallerInstalledToolLocation value to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have set variable to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`);305 assert(tr.stdOutContained('InstallationSuccessful'));306 done();307 });308 it('Get latest pre-release version cache hit from custom feed and password provided', (done: MochaDone) => {309 // Setup the mock runner310 const tp = path.join(__dirname, 'TestSetup.js');311 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);312 // Set the inputs313 process.env[constants.password] = 'pattoken';314 process.env[testConstants.feedId] = 'somefeedid';315 process.env[constants.packageFeedSelector] = constants.customFeed;316 process.env[constants.customFeed] = 'somecustomfeed';317 process.env[testConstants.packageSource] = 'somefeedid';318 process.env[constants.versionSelector] = 'latestPreRelease';319 process.env[testConstants.configFile] = `${process.env[constants.agentTempDirectory]}\\somefeedid.config`;320 process.env[constants.testPlatformVersion] = '';321 process.env[testConstants.expectedTestPlatformVersion] = '15.6.0-preview-20171108-02';322 process.env[testConstants.findLocalToolFirstCallReturnValue] = `VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}`;323 process.env[testConstants.listPackagesReturnCode] = '0';324 // Start the run325 tr.run();326 // Asserts327 assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');328 assert(tr.succeeded, `Task should have succeeded`);329 assert(tr.stdOutContained(`LookingForLatestPreReleaseVersion`), `Should have looked for latest pre-release version.`);330 assert(tr.stdOutContained(`Found the latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have found latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}`);331 assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);332 assert(tr.stdOutContained(`Cache hit for ${process.env[testConstants.expectedTestPlatformVersion]}`), `Expected a cache hit.`);333 assert(tr.stdOutContained(`Set variable VsTestToolsInstallerInstalledToolLocation value to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have set variable to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`);334 assert(tr.stdOutContained('InstallationSuccessful'));335 done();336 });337 it('Get latest pre-release version cache hit from custom feed username and password provided', (done: MochaDone) => {338 // Setup the mock runner339 const tp = path.join(__dirname, 'TestSetup.js');340 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);341 // Set the inputs342 process.env[constants.username] = 'someuser';343 process.env[constants.password] = 'pattoken';344 process.env[testConstants.feedId] = 'somefeedid';345 process.env[constants.packageFeedSelector] = constants.customFeed;346 process.env[constants.customFeed] = 'somecustomfeed';347 process.env[testConstants.packageSource] = 'somefeedid';348 process.env[constants.versionSelector] = 'latestPreRelease';349 process.env[testConstants.configFile] = `${process.env[constants.agentTempDirectory]}\\somefeedid.config`;350 process.env[constants.testPlatformVersion] = '';351 process.env[testConstants.expectedTestPlatformVersion] = '15.6.0-preview-20171108-02';352 process.env[testConstants.findLocalToolFirstCallReturnValue] = `VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}`;353 process.env[testConstants.listPackagesReturnCode] = '0';354 // Start the run355 tr.run();356 // Asserts357 assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');358 assert(tr.succeeded, `Task should have succeeded`);359 assert(tr.stdOutContained(constants.emptyNugetConfig), `Should have written skeleton nuget config file contents.`);360 assert(tr.stdOutContained(`LookingForLatestPreReleaseVersion`), `Should have looked for latest pre-release version.`);361 assert(tr.stdOutContained(`Found the latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have found latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}`);362 assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);363 assert(tr.stdOutContained(`Cache hit for ${process.env[testConstants.expectedTestPlatformVersion]}`), `Expected a cache hit.`);364 assert(tr.stdOutContained(`Set variable VsTestToolsInstallerInstalledToolLocation value to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have set variable to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`);365 assert(tr.stdOutContained(`Deleted file ${process.env[testConstants.configFile]}`), `Should have cleaned up the temp config file.`);366 assert(tr.stdOutContained('InstallationSuccessful'));367 done();368 });369 it('Get latest pre-release version cache miss and download success for custom feed with password', (done: MochaDone) => {370 // Setup the mock runner371 const tp = path.join(__dirname, 'TestSetup.js');372 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);373 // Set the inputs374 process.env[constants.password] = 'pattoken';375 process.env[testConstants.feedId] = 'somefeedid';376 process.env[constants.packageFeedSelector] = constants.customFeed;377 process.env[constants.customFeed] = 'somecustomfeed';378 process.env[testConstants.packageSource] = 'somefeedid';379 process.env[constants.versionSelector] = 'latestPreRelease';380 process.env[testConstants.configFile] = `${process.env[constants.agentTempDirectory]}\\somefeedid.config`;381 process.env[constants.testPlatformVersion] = '';382 process.env[testConstants.expectedTestPlatformVersion] = '15.6.0-preview-20171108-02';383 process.env[testConstants.listPackagesReturnCode] = '0';384 process.env[testConstants.downloadPackageReturnCode] = '0';385 // Start the run386 tr.run();387 // Asserts388 assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');389 assert(tr.succeeded, `Task should have succeeded`);390 assert(tr.stdOutContained(`LookingForLatestPreReleaseVersion`), `Should have looked for latest pre-release version.`);391 assert(tr.stdOutContained(`Found the latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have found latest version to be ${process.env[testConstants.expectedTestPlatformVersion]}`);392 assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);393 assert(tr.stdOutContained(`Could not find Microsoft.TestPlatform.${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache. Fetching it from nuget.`), `Should have encountered a cache miss for ${process.env[testConstants.expectedTestPlatformVersion]}.`);394 assert(tr.stdOutContained(`Downloading Test Platform version ${process.env[testConstants.expectedTestPlatformVersion]} from ${process.env[testConstants.packageSource]} to ${process.env[constants.downloadPath]}.`), `Should have attempted download of version ${process.env[testConstants.expectedTestPlatformVersion]}`);395 assert(tr.stdOutContained(`Caching the downloaded folder temp\\VsTest\\${constants.packageId}.${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have cached ${process.env[testConstants.expectedTestPlatformVersion]}`);396 assert(tr.stdOutContained(`Set variable VsTestToolsInstallerInstalledToolLocation value to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have set variable to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`);397 assert(tr.stdOutContained('InstallationSuccessful'));398 done();399 });400 it('Get latest pre-release version cache hit from custom feed, password provided but writing config fails', (done: MochaDone) => {401 // Setup the mock runner402 const tp = path.join(__dirname, 'TestSetup.js');403 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);404 // Set the inputs405 process.env[constants.password] = 'pattoken';406 process.env[testConstants.feedId] = 'somefeedid';407 process.env[constants.packageFeedSelector] = constants.customFeed;408 process.env[constants.customFeed] = 'somecustomfeed';409 process.env[testConstants.packageSource] = 'somefeedid';410 process.env[constants.versionSelector] = 'latestPreRelease';411 process.env[testConstants.configFile] = `${process.env[constants.agentTempDirectory]}\\somefeedid.config`;412 process.env[constants.testPlatformVersion] = '';413 process.env[testConstants.expectedTestPlatformVersion] = 'x';414 process.env[testConstants.findLocalToolFirstCallReturnValue] = `VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}`;415 process.env[testConstants.listPackagesReturnCode] = '0';416 process.env[testConstants.writeNugetConfigReturnCode] = '1';417 // Start the run418 tr.run();419 // Asserts420 assert(tr.stderr.length !== 0 || tr.errorIssues.length, 'should have written to stderr');421 assert(tr.succeeded, `Task should have succeeded`);422 assert(tr.stdOutContained(`ConfigFileWriteFailed`), `Config file write should have failed and error message for it shown.`);423 assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);424 assert(tr.stdOutContained(`Cache hit for ${process.env[testConstants.expectedTestPlatformVersion]}`), `Expected a cache hit.`);425 assert(tr.stdOutContained('InstallationSuccessful'));426 done();427 });428 it('Get latest pre-release version cache hit from custom feed, password provided but writing config fails and fallback cache lookup fails', (done: MochaDone) => {429 // Setup the mock runner430 const tp = path.join(__dirname, 'TestSetup.js');431 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);432 // Set the inputs433 process.env[constants.password] = 'pattoken';434 process.env[testConstants.feedId] = 'somefeedid';435 process.env[constants.packageFeedSelector] = constants.customFeed;436 process.env[constants.customFeed] = 'somecustomfeed';437 process.env[testConstants.packageSource] = 'somefeedid';438 process.env[constants.versionSelector] = 'latestPreRelease';439 process.env[testConstants.configFile] = `${process.env[constants.agentTempDirectory]}\\somefeedid.config`;440 process.env[constants.testPlatformVersion] = '';441 process.env[testConstants.expectedTestPlatformVersion] = 'x';442 process.env[testConstants.listPackagesReturnCode] = '0';443 process.env[testConstants.writeNugetConfigReturnCode] = '1';444 // Start the run445 tr.run();446 // Asserts447 assert(tr.stderr.length !== 0 || tr.errorIssues.length, 'should have written to stderr');448 assert(tr.failed, `Task should have failed`);449 assert(tr.stdOutContained(`ConfigFileWriteFailed`), `Config file write should have failed and error message for it shown.`);450 assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);451 assert(tr.stdOutContained(`Cache miss for ${process.env[testConstants.expectedTestPlatformVersion]}`), `Should have been a cache miss for ${process.env[testConstants.expectedTestPlatformVersion]}`);452 assert(tr.stdOutContained('NoPackageFoundInCache'), `Should warn no stable package found in cache`);453 assert(tr.stdOutContained('FailedToAcquireTestPlatform'), `Should fail with failed to acquire test platform`);454 done();455 });456 // ***************************************************** Network Share Tests *************************************************************457 it('Get specified package from path provided from network share cache hit', (done: MochaDone) => {458 // Setup the mock runner459 const tp = path.join(__dirname, 'TestSetup.js');460 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);461 // Set the inputs462 process.env[constants.packageFeedSelector] = constants.netShare;463 process.env[testConstants.packageSource] = '\\somesharepath';464 process.env[testConstants.expectedTestPlatformVersion] = '15.6.0-preview-20171108-02';465 process.env[testConstants.findLocalToolFirstCallReturnValue] = `VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}`;466 process.env[constants.netShare] = `\\\\somesharepath\\Microsoft.Testplatform.${process.env[testConstants.expectedTestPlatformVersion]}.nupkg`;467 process.env[testConstants.listPackagesReturnCode] = '0';468 // Start the run469 tr.run();470 // Asserts471 assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');472 assert(tr.succeeded, `Task should have succeeded`);473 assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);474 assert(tr.stdOutContained(`Cache hit for ${process.env[testConstants.expectedTestPlatformVersion]}`), `Expected a cache hit.`);475 assert(tr.stdOutContained(`Set variable VsTestToolsInstallerInstalledToolLocation value to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have set variable to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`);476 assert(tr.stdOutContained('InstallationSuccessful'));477 done();478 });479 it('Get specified package from path provided from network share cache miss and copy successful', (done: MochaDone) => {480 // Setup the mock runner481 const tp = path.join(__dirname, 'TestSetup.js');482 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);483 // Set the inputs484 process.env[constants.packageFeedSelector] = constants.netShare;485 process.env[testConstants.expectedTestPlatformVersion] = '15.6.0-preview-20171108-02';486 process.env[constants.netShare] = `\\\\somesharepath\\Microsoft.Testplatform.${process.env[testConstants.expectedTestPlatformVersion]}.nupkg`;487 process.env[testConstants.packageSource] = process.env[constants.netShare];488 process.env[testConstants.listPackagesReturnCode] = '0';489 // Start the run490 tr.run();491 // Asserts492 assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');493 assert(tr.succeeded, `Task should have succeeded`);494 assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);495 assert(tr.stdOutContained(`Could not find Microsoft.TestPlatform.${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache. Fetching it from nuget.`), `Should have encountered a cache miss for ${process.env[testConstants.expectedTestPlatformVersion]}.`);496 assert(tr.stdOutContained(`Set variable VsTestToolsInstallerInstalledToolLocation value to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have set variable to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`);497 assert(tr.stdOutContained('InstallationSuccessful'));498 done();499 });500 it('Get specified package from path provided from network share cache miss share and copy unsuccessful but fallback cache lookup successful', (done: MochaDone) => {501 // Setup the mock runner502 const tp = path.join(__dirname, 'TestSetup.js');503 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);504 // Set the inputs505 process.env[constants.packageFeedSelector] = constants.netShare;506 process.env[testConstants.expectedTestPlatformVersion] = '15.6.0-preview-20171108-02';507 process.env[constants.netShare] = `\\\\somesharepath\\Microsoft.Testplatform.${process.env[testConstants.expectedTestPlatformVersion]}.nupkg`;508 process.env[testConstants.packageSource] = process.env[constants.netShare];509 process.env[testConstants.listPackagesReturnCode] = '0';510 process.env[testConstants.downloadPackageReturnCode] = '1';511 process.env[testConstants.findLocalToolFirstCallReturnValue] = ``;512 process.env[testConstants.findLocalToolSecondCallReturnValue] = `VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}`;513 // Start the run514 tr.run();515 // Asserts516 assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');517 assert(tr.succeeded, `Task should have succeeded`);518 assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);519 assert(tr.stdOutContained(`Could not find Microsoft.TestPlatform.${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache. Fetching it from nuget.`), `Should have encountered a cache miss for ${process.env[testConstants.expectedTestPlatformVersion]}.`);520 assert(tr.stdOutContained(`Set variable VsTestToolsInstallerInstalledToolLocation value to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`), `Should have set variable to VsTest\\${process.env[testConstants.expectedTestPlatformVersion]}.`);521 assert(tr.stdOutContained('InstallationSuccessful'));522 done();523 });524 it('Get specified package from path provided from network share cache miss and copy unsuccessful and fallback cache lookup unsuccessful', (done: MochaDone) => {525 // Setup the mock runner526 const tp = path.join(__dirname, 'TestSetup.js');527 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);528 // Set the inputs529 process.env[constants.packageFeedSelector] = constants.netShare;530 process.env[testConstants.expectedTestPlatformVersion] = '15.6.0-preview-20171108-02';531 process.env[constants.netShare] = `\\\\somesharepath\\Microsoft.Testplatform.${process.env[testConstants.expectedTestPlatformVersion]}.nupkg`;532 process.env[testConstants.packageSource] = process.env[constants.netShare];533 process.env[testConstants.listPackagesReturnCode] = '0';534 process.env[testConstants.downloadPackageReturnCode] = '1';535 // Start the run536 tr.run();537 // Asserts538 assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');539 assert(tr.failed, `Task should have succeeded`);540 assert(tr.stdOutContained(`Looking for version ${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache.`), `Should have looked for ${process.env[testConstants.expectedTestPlatformVersion]} in the cache.`);541 assert(tr.stdOutContained(`Could not find Microsoft.TestPlatform.${process.env[testConstants.expectedTestPlatformVersion]} in the tools cache. Fetching it from nuget.`), `Should have encountered a cache miss for ${process.env[testConstants.expectedTestPlatformVersion]}.`);542 assert(tr.stdOutContained(`Cache miss for ${process.env[testConstants.expectedTestPlatformVersion]}`), `Should have been a cache miss for ${process.env[testConstants.expectedTestPlatformVersion]}`);543 assert(tr.stdOutContained('NoPackageFoundInCache'), `Should warn no stable package found in cache`);544 assert(tr.stdOutContained('FailedToAcquireTestPlatform'), `Should fail with failed to acquire test platform`);545 done();546 });547 it('Get specified package from path provided from network share invalid filename', (done: MochaDone) => {548 // Setup the mock runner549 const tp = path.join(__dirname, 'TestSetup.js');550 const tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);551 // Set the inputs552 process.env[constants.packageFeedSelector] = constants.netShare;553 process.env[testConstants.packageSource] = '\\somesharepath';554 process.env[testConstants.expectedTestPlatformVersion] = '15.6.0-preview-20171108-02';555 process.env[constants.netShare] = `\\\\somesharepath\\Miiiicrosoft.Testplatform.${process.env[testConstants.expectedTestPlatformVersion]}.nupkg`;556 process.env[testConstants.listPackagesReturnCode] = '0';557 // Start the run558 tr.run();559 // Asserts560 assert(tr.stderr.length === 0 || tr.errorIssues.length, 'should not have written to stderr');561 assert(tr.failed, `Task should have failed`);562 assert(tr.stdOutContained(`UnexpectedFileName`));563 done();564 });...

Full Screen

Full Screen

TestConstants.js

Source:TestConstants.js Github

copy

Full Screen

1function TestConstants() {2}3const POOLCONTRACT = artifacts.require('./pools/Pool.sol');4TestConstants.baseGasAmount = 400000;5// needs to work with the base config. Cannot be more than MAX_CONTRIBUTION or6// less than MIN_CONTRIBUTION7TestConstants.baseAccountAmount = 50;8TestConstants.poolContract;9TestConstants.OptionUint256 = {10 MAX_ALLOCATION: 0,11 MIN_CONTRIBUTION: 1,12 MAX_CONTRIBUTION: 2,13 ADMIN_FEE_PERCENT_DECIMALS: 3,14 ADMIN_FEE_PERCENTAGE: 415};16TestConstants.PoolStateUint8 = {17 OPEN: 0,18 CLOSED: 1,19 AWAITING_TOKENS: 2,20 COMPLETED: 3,21 CANCELLED: 422};23TestConstants.OptionBool = {24 HAS_WHITELIST: 0,25 ADMIN_FEE_PAYOUT_TOKENS: 126};27TestConstants.getBaseConfigsUint256 = function () {28 return [1000, //MAX_ALLOCATION29 2, //MIN_CONTRIBUTION30 75, //MAX_CONTRIBUTION31 5, //ADMIN_FEE_PERCENT_DECIMALS32 500000// ADMIN_FEE_PERCENTAGE 5%33 ];34};35TestConstants.getBaseConfigsBoolFalse = function () {36 return [false, false //HAS_WHITELIST = false37 ];38};39TestConstants.getBaseConfigsBoolTrue = function () {40 return [true, false //HAS_WHITELIST = true41 ];42};43TestConstants.setPoolContract = function (contract) {44 TestConstants.poolContract = contract;45};46// Creates a pool contract with a whitelist disabled.47// Consumes a contract address and an array of admin addresses.48// Returns the address of the corresponding pool that is created.49TestConstants.createBasePoolNoWhitelist = async function (contract, adminAccounts) {50 let poolIdAddress = await contract.createPool.call(51 adminAccounts,52 TestConstants.getBaseConfigsUint256(),53 TestConstants.getBaseConfigsBoolFalse(),54 {from: adminAccounts[0]}55 );56 await contract.createPool(57 adminAccounts,58 TestConstants.getBaseConfigsUint256(),59 TestConstants.getBaseConfigsBoolFalse(),60 {from: adminAccounts[0]}61 );62 let pool = POOLCONTRACT.at(poolIdAddress);63 TestConstants.setPoolContract(pool);64 return pool;65};66// Creates a pool contract with a whitelist enabled.67// Consumes a contract address and an array of admin addresses.68// Returns the address of the corresponding pool that is created.69TestConstants.createBasePoolWhitelist = async function (contract, adminAccounts) {70 let poolIdAddress = await contract.createPool.call(71 adminAccounts,72 TestConstants.getBaseConfigsUint256(),73 TestConstants.getBaseConfigsBoolTrue(),74 {from: adminAccounts[0]}75 );76 await contract.createPool(77 adminAccounts,78 TestConstants.getBaseConfigsUint256(),79 TestConstants.getBaseConfigsBoolTrue(),80 {from: adminAccounts[0]}81 );82 let pool = POOLCONTRACT.at(poolIdAddress);83 TestConstants.setPoolContract(pool);84 return pool;85};86// Creates a pool contract with a set of custom configurations.87// Returns the address of the corresponding pool that is created.88TestConstants.createCustomPool = async function (contract, configsUINT, configsBool, adminAccounts) {89 let poolIdAddress = await contract.createPool.call(90 adminAccounts,91 configsUINT,92 configsBool,93 {from: adminAccounts[0]}94 );95 await contract.createPool(96 adminAccounts,97 configsUINT,98 configsBool,99 {from: adminAccounts[0]}100 );101 let pool = POOLCONTRACT.at(poolIdAddress);102 TestConstants.setPoolContract(pool);103 return pool;104};105// Consumes an array of accounts, and sends the baseAccountAmmount of wei to the test pool contract for each address.106TestConstants.sendWeiToContract = async function (accounts, values) {107 for (let i = 0; i < accounts.length; ++i) {108 await TestConstants.poolContract.sendTransaction({109 from: accounts[i], gas: TestConstants.baseGasAmount, value: values[i]110 });111 }112};113// Consumes an array of accounts, and sends the baseAccountAmmount of wei to the test pool contract for each address.114TestConstants.sendWeiToContractDefault = async function (accounts) {115 for (let i = 0; i < accounts.length; ++i) {116 await TestConstants.poolContract.sendTransaction({117 from: accounts[i], gas: TestConstants.baseGasAmount, value: TestConstants.baseAccountAmount118 });119 }120};121// Checks if the pool contract holds the right balances.122// Consumes an array of addresses, and an array of values.123// Returns true if the values are equal.124TestConstants.checkPoolBalances = async function (accounts, balances) {125 for (let i = 0; i < accounts.length; ++i) {126 let actual = await TestConstants.poolContract.swimmers(accounts[i]);127 let expected = balances[i];128 if (actual != expected){129 return false;130 }131 }132 return true;133};134// Checks if the ERC20 test token holds the right balances.135// Consumes an array of addresses, and an array of values.136// Returns true if the values are equal.137TestConstants.checkTokenBalances = async function (accounts, balances, testTokenContract) {138 for (let i = 0; i < accounts.length; ++i) {139 let actual = await testTokenContract.balanceOf(accounts[i]);140 let expected = balances[i];141 if (actual != expected){142 return false;143 }144 }145 return true;146};147// Consumes an array of addresses, and calls Pool.Claim() for each address.148TestConstants.claimTokens = async function (accounts) {149 for (let i = 0; i < accounts.length; ++i) {150 await TestConstants.poolContract.claim({151 from: accounts[i]152 });153 }154};155// Consumes an array of addresses, and calls Pool.Refund() for each address.156TestConstants.claimRefunds = async function (accounts) {157 for (let i = 0; i < accounts.length; ++i) {158 await TestConstants.poolContract.refund({159 from: accounts[i]160 });161 }162};...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2wpt.testConstants();3var wpt = require('./wpt.js');4wpt.testConstants();5var wpt = require('./wpt.js');6wpt.testConstants();7var wpt = require('./wpt.js');8wpt.testConstants();9var wpt = require('./wpt.js');10wpt.testConstants();11var wpt = require('./wpt.js');12wpt.testConstants();13var wpt = require('./wpt.js');14wpt.testConstants();15var wpt = require('./wpt.js');16wpt.testConstants();17var wpt = require('./wpt.js');18wpt.testConstants();19var wpt = require('./wpt.js');20wpt.testConstants();21var wpt = require('./wpt.js');22wpt.testConstants();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt');2wpt.testConstants();3exports.testConstants = function() {4 console.log('Test Constants');5 console.log('API_KEY: ' + API_KEY);6 console.log('API_URL: ' + API_URL);7 console.log('API_VERSION: ' + API_VERSION);8 console.log('API_FORMAT: ' + API_FORMAT);9 console.log('API_REQUEST: ' + API_REQUEST);10 console.log('API_RESPONSE: ' + API_RESPONSE);11 console.log('API_TEST: ' + API_TEST);12 console.log('API_LOCATION: ' + API_LOCATION);13 console.log('API_STATUS: ' + API_STATUS);14 console.log('API_RESULTS: ' + API_RESULTS);15 console.log('API_JSON: ' + API_JSON);16 console.log('API_XML: ' + API_XML);17 console.log('API_PNG: ' + API_PNG);18 console.log('API_HAR: ' + API_HAR);19 console.log('API_PAGE_SPEED: ' + API_PAGE_SPEED);20 console.log('API_PAGE_SPEED_MOBILE: ' + API_PAGE_SPEED_MOBILE);21 console.log('API_VIDEO: ' + API_VIDEO);22 console.log('API_VIDEO_MOBILE: ' + API_VIDEO_MOBILE);23 console.log('API_THUMBNAIL: ' + API_THUMBNAIL);24 console.log('API_THUMBNAIL_MOBILE: ' + API_THUMBNAIL_MOBILE);25 console.log('API_REQUESTS: ' + API_REQUESTS);26 console.log('API_REQUESTS_MOBILE: ' + API_REQUESTS_MOBILE);27 console.log('API_PAGESPEED: ' + API_PAGESPEED);28 console.log('API_PAGESPEED_MOBILE: ' + API_PAGESPEED_MOBILE);29 console.log('API_PAGESPEED_SUMMARY: ' + API_PAGESPEED_SUMMARY);30 console.log('API_PAGESPEED_SUMMARY_MOBILE: ' + API_PAGESPEED_SUMMARY_MOBILE);31 console.log('API_PAGESPEED_RULES: ' + API_PAGESPEED_RULES);32 console.log('API_PAGESPEED_RULES_MOBILE: ' + API_PAGESPEED_RULES_MOBILE);33 console.log('API_PAGESPEED_STRINGS: ' + API_PAGESPEED_STRINGS);34 console.log('API_PAGESPEED_STRINGS_MOBILE: ' + API_PAGESPEED_STRINGS_MOBILE);35 console.log('API_PAGESPEED_FORMAT: ' + API_PAGESPEED

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptTest = require('./wptTest.js');2var testConstants = wptTest.testConstants;3var testConstants2 = wptTest.testConstants2;4var wptTest2 = require('./wptTest2.js');5var testConstants3 = wptTest2.testConstants;6var wptTest3 = require('./wptTest3.js');7var testConstants4 = wptTest3.testConstants;8var wptTest4 = require('./wptTest4.js');9var testConstants5 = wptTest4.testConstants;10var wptTest5 = require('./wptTest5.js');11var testConstants6 = wptTest5.testConstants;12var wptTest6 = require('./wptTest6.js');13var testConstants7 = wptTest6.testConstants;14var wptTest7 = require('./wptTest7.js');15var testConstants8 = wptTest7.testConstants;16var wptTest8 = require('./wptTest8.js');17var testConstants9 = wptTest8.testConstants;18var wptTest9 = require('./wptTest9.js');19var testConstants10 = wptTest9.testConstants;20var wptTest10 = require('./wptTest10.js');21var testConstants11 = wptTest10.testConstants;22var wptTest11 = require('./wptTest11.js');23var testConstants12 = wptTest11.testConstants;24var wptTest12 = require('./wptTest12.js');25var testConstants13 = wptTest12.testConstants;26var wptTest13 = require('./wptTest13.js');

Full Screen

Using AI Code Generation

copy

Full Screen

1var test = new wpt.testConstants();2var test = new wpt.testConstants();3test.testConstants();4var test = new wpt.testConstants();5test.testConstants();6var test = new wpt.testInfo();7test.testInfo();8var test = new wpt.testStatus();9test.testStatus();10var test = new wpt.testResults();11test.testResults();12var test = new wpt.testResultsURL();13test.testResultsURL();14var test = new wpt.testResultsPageSpeed();15test.testResultsPageSpeed();16var test = new wpt.testResultsHar();17test.testResultsHar();18var test = new wpt.testResultsHarData();19test.testResultsHarData();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful