diff --git a/clients/client/test/client_test.js b/clients/client/test/client_test.js index 436450e4b7b..d74615d652a 100644 --- a/clients/client/test/client_test.js +++ b/clients/client/test/client_test.js @@ -1,10 +1,11 @@ -suite('client requests/responses', function() { - let taskcluster = require('../'); - let assert = require('assert'); - let path = require('path'); - let nock = require('nock'); - let MonitorManager = require('taskcluster-lib-monitor'); - +const taskcluster = require('../'); +const assert = require('assert'); +const path = require('path'); +const nock = require('nock'); +const MonitorManager = require('taskcluster-lib-monitor'); +const testing = require('taskcluster-lib-testing'); + +suite(testing.suiteName(), function() { // This suite exercises the request and response functionality of // the client against a totally fake service defined by this reference // and implemented via Nock. diff --git a/clients/client/test/credinfo_test.js b/clients/client/test/credinfo_test.js index 305048cbb31..d8e7e34e80f 100644 --- a/clients/client/test/credinfo_test.js +++ b/clients/client/test/credinfo_test.js @@ -1,8 +1,9 @@ -suite('taskcluster.credentialInfo', function() { - let taskcluster = require('../'); - let assert = require('assert'); - let nock = require('nock'); +const taskcluster = require('../'); +const assert = require('assert'); +const nock = require('nock'); +const testing = require('taskcluster-lib-testing'); +suite(testing.suiteName(), function() { teardown(function() { assert(nock.isDone()); nock.cleanAll(); diff --git a/clients/client/test/creds_test.js b/clients/client/test/creds_test.js index 8830f224c6b..3f96003095b 100644 --- a/clients/client/test/creds_test.js +++ b/clients/client/test/creds_test.js @@ -1,9 +1,10 @@ -suite('client credential handling', function() { - let taskcluster = require('../'); - let assert = require('assert'); - let request = require('superagent'); - let _ = require('lodash'); +const taskcluster = require('../'); +const assert = require('assert'); +const request = require('superagent'); +const _ = require('lodash'); +const testing = require('taskcluster-lib-testing'); +suite(testing.suiteName(), function() { // This suite exercises the credential-handling functionality of the client // against a the auth service's testAuthenticate endpoint. diff --git a/clients/client/test/retry_test.js b/clients/client/test/retry_test.js index 687fe660155..859a649bd7a 100644 --- a/clients/client/test/retry_test.js +++ b/clients/client/test/retry_test.js @@ -1,14 +1,14 @@ -suite('retry-test', function() { - const taskcluster = require('../'); - const assert = require('assert'); - const SchemaSet = require('taskcluster-lib-validate'); - const MonitorManager = require('taskcluster-lib-monitor'); - const APIBuilder = require('taskcluster-lib-api'); - const testing = require('taskcluster-lib-testing'); - const App = require('taskcluster-lib-app'); - const http = require('http'); - const httpProxy = require('http-proxy'); +const taskcluster = require('../'); +const assert = require('assert'); +const SchemaSet = require('taskcluster-lib-validate'); +const MonitorManager = require('taskcluster-lib-monitor'); +const APIBuilder = require('taskcluster-lib-api'); +const testing = require('taskcluster-lib-testing'); +const App = require('taskcluster-lib-app'); +const http = require('http'); +const httpProxy = require('http-proxy'); +suite(testing.suiteName(), function() { const PROXY_PORT = 60551; const rootUrl = `http://localhost:${PROXY_PORT}`; let proxier; diff --git a/clients/client/test/utils_test.js b/clients/client/test/utils_test.js index 232a9c9586d..9c242264ba6 100644 --- a/clients/client/test/utils_test.js +++ b/clients/client/test/utils_test.js @@ -1,8 +1,9 @@ -suite('taskcluster utilities', function() { - let taskcluster = require('../'); - let parseTime = require('../src/parsetime'); - let assert = require('assert'); +const taskcluster = require('../'); +const parseTime = require('../src/parsetime'); +const assert = require('assert'); +const testing = require('taskcluster-lib-testing'); +suite(testing.suiteName(), function() { test('parseTime 1 year', function() { assert.equal(parseTime('1y').years, 1); assert.equal(parseTime('1 yr').years, 1); diff --git a/libraries/api/test/auth_test.js b/libraries/api/test/auth_test.js index 4dd57223f21..1a8d70a35f7 100644 --- a/libraries/api/test/auth_test.js +++ b/libraries/api/test/auth_test.js @@ -10,7 +10,7 @@ const testing = require('taskcluster-lib-testing'); const path = require('path'); const debug = require('debug')('auth_test'); -suite('api/auth', function() { +suite(testing.suiteName(), function() { // Reference for test api server let _apiServer = null; diff --git a/libraries/api/test/context_test.js b/libraries/api/test/context_test.js index 999401f417e..09ed963790e 100644 --- a/libraries/api/test/context_test.js +++ b/libraries/api/test/context_test.js @@ -6,8 +6,9 @@ const request = require('superagent'); const slugid = require('slugid'); const path = require('path'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); -suite('API (context)', function() { +suite(testing.suiteName(), function() { const rootUrl = 'http://localhost:4321'; test('Provides context', async () => { // Create test api diff --git a/libraries/api/test/errors_test.js b/libraries/api/test/errors_test.js index 5412cbba3ef..49c9c799530 100644 --- a/libraries/api/test/errors_test.js +++ b/libraries/api/test/errors_test.js @@ -5,8 +5,9 @@ const helper = require('./helper'); const _ = require('lodash'); const libUrls = require('taskcluster-lib-urls'); const expressError = require('../src/middleware/express-error.js'); +const testing = require('taskcluster-lib-testing'); -suite('api/errors', function() { +suite(testing.suiteName(), function() { // Create test api const builder = new APIBuilder({ title: 'Test Api', diff --git a/libraries/api/test/expressions_test.js b/libraries/api/test/expressions_test.js index b782d605ddc..e47ff95ad91 100644 --- a/libraries/api/test/expressions_test.js +++ b/libraries/api/test/expressions_test.js @@ -1,7 +1,8 @@ const assert = require('assert'); const ScopeExpressionTemplate = require('../src/expressions'); +const testing = require('taskcluster-lib-testing'); -suite('expression expansion success', function() { +suite(testing.suiteName(), function() { function scenario(expr, params, result, shouldFail=false) { return () => { diff --git a/libraries/api/test/middleware_test.js b/libraries/api/test/middleware_test.js index 63182a5ec76..e41b1755e06 100644 --- a/libraries/api/test/middleware_test.js +++ b/libraries/api/test/middleware_test.js @@ -1,8 +1,8 @@ const assert = require('assert'); const APIBuilder = require('../'); +const testing = require('taskcluster-lib-testing'); -suite('api/middleware', function() { - +suite(testing.suiteName(), function() { test('middleware is exported', function() { assert(APIBuilder.middleware); }); diff --git a/libraries/api/test/noncemanager_test.js b/libraries/api/test/noncemanager_test.js index 0c752b33f64..3dfd05756f4 100644 --- a/libraries/api/test/noncemanager_test.js +++ b/libraries/api/test/noncemanager_test.js @@ -2,8 +2,9 @@ const API = require('../src/api'); const assert = require('assert'); const Promise = require('promise'); const debug = require('debug')('base:test:nonceManager'); +const testing = require('taskcluster-lib-testing'); -suite('nonceManager test', function() { +suite(testing.suiteName(), function() { // Create a new nonceManager for each test let nonceManager = null; setup(function() { diff --git a/libraries/api/test/publish_test.js b/libraries/api/test/publish_test.js index eef46aa4403..0df8de500c2 100644 --- a/libraries/api/test/publish_test.js +++ b/libraries/api/test/publish_test.js @@ -3,8 +3,9 @@ const config = require('taskcluster-lib-config'); const aws = require('aws-sdk'); const assert = require('assert'); const libUrls = require('taskcluster-lib-urls'); +const testing = require('taskcluster-lib-testing'); -suite('api/publish', function() { +suite(testing.suiteName(), function() { const cfg = config({}); if (!cfg.aws || !cfg.referenceTestBucket) { diff --git a/libraries/api/test/responsetimer_test.js b/libraries/api/test/responsetimer_test.js index 1c135615b50..6d75756bc1c 100644 --- a/libraries/api/test/responsetimer_test.js +++ b/libraries/api/test/responsetimer_test.js @@ -4,8 +4,9 @@ const APIBuilder = require('../'); const MonitorManager = require('taskcluster-lib-monitor'); const helper = require('./helper'); const libUrls = require('taskcluster-lib-urls'); +const testing = require('taskcluster-lib-testing'); -suite('api/responsetimer', function() { +suite(testing.suiteName(), function() { // Create test api const builder = new APIBuilder({ title: 'Test Api', diff --git a/libraries/api/test/route_test.js b/libraries/api/test/route_test.js index 3a755f00c7f..4738895d461 100644 --- a/libraries/api/test/route_test.js +++ b/libraries/api/test/route_test.js @@ -4,8 +4,9 @@ const APIBuilder = require('../'); const slugid = require('slugid'); const helper = require('./helper'); const libUrls = require('taskcluster-lib-urls'); +const testing = require('taskcluster-lib-testing'); -suite('api/route', function() { +suite(testing.suiteName(), function() { const u = path => libUrls.api(helper.rootUrl, 'test', 'v1', path); // Create test api diff --git a/libraries/api/test/scopes_test.js b/libraries/api/test/scopes_test.js index 1ada7696422..dab7caee658 100644 --- a/libraries/api/test/scopes_test.js +++ b/libraries/api/test/scopes_test.js @@ -1,7 +1,8 @@ const assert = require('assert'); const APIBuilder = require('../'); +const testing = require('taskcluster-lib-testing'); -suite('api/route', function() { +suite(testing.suiteName(), function() { // Create test api const builder = new APIBuilder({ title: 'Test Api', diff --git a/libraries/api/test/validate_test.js b/libraries/api/test/validate_test.js index a3136557eb5..9e6f66adc94 100644 --- a/libraries/api/test/validate_test.js +++ b/libraries/api/test/validate_test.js @@ -6,8 +6,9 @@ const libUrls = require('taskcluster-lib-urls'); const path = require('path'); const SchemaSet = require('taskcluster-lib-validate'); const MonitorManager = require('taskcluster-lib-monitor'); +const testing = require('taskcluster-lib-testing'); -suite('api/validate', function() { +suite(testing.suiteName(), function() { const u = path => libUrls.api(helper.rootUrl, 'test', 'v1', path); // Create test api diff --git a/libraries/app/test/app_test.js b/libraries/app/test/app_test.js index a15a003060e..8a962d96dca 100644 --- a/libraries/app/test/app_test.js +++ b/libraries/app/test/app_test.js @@ -3,8 +3,9 @@ let App = require('../'); let request = require('superagent'); let express = require('express'); let isUUID = require('is-uuid'); +const testing = require('taskcluster-lib-testing'); -suite('app', function() { +suite(testing.suiteName(), function() { // Test app creation suite('app({port: 1459})', function() { diff --git a/libraries/azure/test/basic_test.js b/libraries/azure/test/basic_test.js deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/libraries/azure/test/index_test.js b/libraries/azure/test/index_test.js index 12f2a25cfaf..b41171fef5e 100644 --- a/libraries/azure/test/index_test.js +++ b/libraries/azure/test/index_test.js @@ -3,8 +3,9 @@ const {sasCredentials} = require('..'); const nock = require('nock'); const url = require('url'); const libUrls = require('taskcluster-lib-urls'); +const testing = require('taskcluster-lib-testing'); -suite('index_test.js', function() { +suite(testing.suiteName(), function() { let scope; const mockAzureTableSAS = (accessLevel) => { diff --git a/libraries/config/test/config_test.js b/libraries/config/test/config_test.js index 243404cd62c..d7d43c5c80a 100644 --- a/libraries/config/test/config_test.js +++ b/libraries/config/test/config_test.js @@ -1,7 +1,9 @@ -suite('config', function() { - let config = require('../'); - let path = require('path'); - let assume = require('assume'); +const config = require('../'); +const path = require('path'); +const assume = require('assume'); +const testing = require('taskcluster-lib-testing'); + +suite(testing.suiteName(), function() { test('load yaml', () => { let cfg = config({ diff --git a/libraries/docs/test/main_test.js b/libraries/docs/test/main_test.js index e90069c9d53..4c4edf2d9d8 100644 --- a/libraries/docs/test/main_test.js +++ b/libraries/docs/test/main_test.js @@ -10,6 +10,7 @@ const APIBuilder = require('taskcluster-lib-api'); const {Exchanges} = require('taskcluster-lib-pulse'); const MockS3UploadStream = require('./mockS3UploadStream'); const tmp = require('tmp'); +const testing = require('taskcluster-lib-testing'); function assertInTarball(shoulds, tarball) { shoulds.push('metadata.json'); @@ -38,7 +39,7 @@ function assertInTarball(shoulds, tarball) { }); } -suite('documenter', () => { +suite(testing.suiteName(), () => { let schemaset = null; let exchanges = null; let references = null; diff --git a/libraries/docs/test/package_test.js b/libraries/docs/test/package_test.js deleted file mode 100644 index 1b565ee6bb4..00000000000 --- a/libraries/docs/test/package_test.js +++ /dev/null @@ -1,15 +0,0 @@ -suite('Package', () => { - let assert = require('assert'); - let pack = require('../package.json'); - let exec = require('child_process'); - - test('git tag must match package version', function() { - let tag = exec.execSync('git tag -l --contains HEAD').toString().trim(); - if (tag === '') { - console.log(' No git tag, no need to check tag!'); - this.skip(); - } - assert.equal('v' + pack.version, tag); - }); - -}); diff --git a/libraries/iterate/test/iterate_test.js b/libraries/iterate/test/iterate_test.js index 65e4b837611..08bfbc7c313 100644 --- a/libraries/iterate/test/iterate_test.js +++ b/libraries/iterate/test/iterate_test.js @@ -3,6 +3,7 @@ let sandbox = require('sinon').createSandbox(); let assume = require('assume'); let debug = require('debug')('iterate-test'); let MonitorManager = require('taskcluster-lib-monitor'); +const testing = require('taskcluster-lib-testing'); let possibleEvents = [ 'started', @@ -49,7 +50,7 @@ class IterateEvents { } -suite('Iterate', () => { +suite(testing.suiteName(), () => { let manager; let monitor; diff --git a/libraries/iterate/test/watchdog_test.js b/libraries/iterate/test/watchdog_test.js index 1b3bc69856f..9a9b649c466 100644 --- a/libraries/iterate/test/watchdog_test.js +++ b/libraries/iterate/test/watchdog_test.js @@ -1,8 +1,9 @@ let subject = require('../src/watchdog'); let sinon = require('sinon'); let assume = require('assume'); +const testing = require('taskcluster-lib-testing'); -suite('watchdog', function() { +suite(testing.suiteName(), function() { let events, start; setup(function() { diff --git a/libraries/monitor/test/base_test.js b/libraries/monitor/test/base_test.js index 341fe358813..cf521d51529 100644 --- a/libraries/monitor/test/base_test.js +++ b/libraries/monitor/test/base_test.js @@ -5,7 +5,7 @@ const testing = require('taskcluster-lib-testing'); const stream = require('stream'); const MonitorManager = require('../src'); -suite('BaseMonitor', function() { +suite(testing.suiteName(), function() { let manager, monitor, messages; setup(function() { diff --git a/libraries/monitor/test/logger_test.js b/libraries/monitor/test/logger_test.js index 4ab680e804a..ec0f80fe562 100644 --- a/libraries/monitor/test/logger_test.js +++ b/libraries/monitor/test/logger_test.js @@ -2,8 +2,9 @@ const assert = require('assert'); const stream = require('stream'); const Ajv = require('ajv'); const MonitorManager = require('../src'); +const testing = require('taskcluster-lib-testing'); -suite('Logging', function() { +suite(testing.suiteName(), function() { let manager, monitor, messages, destination; setup(function() { diff --git a/libraries/monitor/test/registry_test.js b/libraries/monitor/test/registry_test.js index 83455af3ccd..c2a7f628e82 100644 --- a/libraries/monitor/test/registry_test.js +++ b/libraries/monitor/test/registry_test.js @@ -1,7 +1,8 @@ const assert = require('assert'); const MonitorManager = require('../src'); +const testing = require('taskcluster-lib-testing'); -suite('Registry', function() { +suite(testing.suiteName(), function() { test('can add custom message types', function() { const manager = new MonitorManager({ diff --git a/libraries/pulse/test/client_test.js b/libraries/pulse/test/client_test.js index 15ccd8b3300..24c58bdd540 100644 --- a/libraries/pulse/test/client_test.js +++ b/libraries/pulse/test/client_test.js @@ -5,6 +5,7 @@ const assume = require('assume'); const debugModule = require('debug'); const libMonitor = require('taskcluster-lib-monitor'); const slugid = require('slugid'); +const testing = require('taskcluster-lib-testing'); const PULSE_CONNECTION_STRING = process.env.PULSE_CONNECTION_STRING; @@ -298,7 +299,7 @@ const connectionTests = connectionString => { }); }; -suite('Client', function() { +suite(testing.suiteName(), function() { suite('with RabbitMQ', function() { suiteSetup(function() { if (!PULSE_CONNECTION_STRING) { diff --git a/libraries/pulse/test/consumer_test.js b/libraries/pulse/test/consumer_test.js index 17fc512b740..34a46970a66 100644 --- a/libraries/pulse/test/consumer_test.js +++ b/libraries/pulse/test/consumer_test.js @@ -4,10 +4,11 @@ const assume = require('assume'); const debugModule = require('debug'); const libMonitor = require('taskcluster-lib-monitor'); const assert = require('assert'); +const testing = require('taskcluster-lib-testing'); const PULSE_CONNECTION_STRING = process.env.PULSE_CONNECTION_STRING; -suite('consumer_test.js', function() { +suite(testing.suiteName(), function() { suite('PulseConsumer', function() { // use a unique name for each test run, just to ensure nothing interferes const unique = new Date().getTime().toString(); diff --git a/libraries/pulse/test/credentials_test.js b/libraries/pulse/test/credentials_test.js index 33815676357..ddf24893ed5 100644 --- a/libraries/pulse/test/credentials_test.js +++ b/libraries/pulse/test/credentials_test.js @@ -1,8 +1,9 @@ const {pulseCredentials} = require('../src'); const assert = require('assert'); const assume = require('assume'); +const testing = require('taskcluster-lib-testing'); -suite('pulseCredentials', function() { +suite(testing.suiteName(), function() { test('missing arguments are an error', async function() { assume(() => pulseCredentials({password: 'pw', hostname: 'h', vhost: 'v'})) .throws(/username/); diff --git a/libraries/pulse/test/publisher_test.js b/libraries/pulse/test/publisher_test.js index 23dc4df678f..1e5d88048a3 100644 --- a/libraries/pulse/test/publisher_test.js +++ b/libraries/pulse/test/publisher_test.js @@ -6,11 +6,11 @@ const assert = require('assert'); const libMonitor = require('taskcluster-lib-monitor'); const SchemaSet = require('taskcluster-lib-validate'); const libUrls = require('taskcluster-lib-urls'); -const libTesting = require('taskcluster-lib-testing'); +const testing = require('taskcluster-lib-testing'); const PULSE_CONNECTION_STRING = process.env.PULSE_CONNECTION_STRING; -suite('publisher_test.js', function() { +suite(testing.suiteName(), function() { const exchangeOptions = { serviceName: 'lib-pulse', projectName: 'taskcluster-lib-pulse', @@ -248,7 +248,7 @@ suite('publisher_test.js', function() { test('publish a message', async function() { await publisher.eggHatched({eggId: 'yolks-on-you'}); - await libTesting.poll(async () => { + await testing.poll(async () => { assert.equal(messages.length, 1); const got = messages[0]; assert.equal(got.fields.routingKey, 'yolks-on-you'); @@ -264,7 +264,7 @@ suite('publisher_test.js', function() { const eggIds = [...Array(10000).keys()].map(id => id.toString()); await Promise.all(eggIds.map(eggId => publisher.eggHatched({eggId}))); - await libTesting.poll(async () => { + await testing.poll(async () => { const got = messages.map(msg => msg.fields.routingKey); assert.deepEqual(got.length, eggIds.length, 'got expected number of messages'); assert.deepEqual(got.sort(), eggIds.sort(), 'got exactly the expected messages'); @@ -278,7 +278,7 @@ suite('publisher_test.js', function() { client.connections[0].amqp.close(); // force closure.. await Promise.all(['x', 'y', 'z'].map(eggId => publisher.eggHatched({eggId}))); - await libTesting.poll(async () => { + await testing.poll(async () => { const got = messages.map(msg => msg.fields.routingKey).sort(); assert.deepEqual(got, ['a', 'b', 'c', 'i', 'j', 'k', 'l', 'm', 'x', 'y', 'z']); }); diff --git a/libraries/references/test/action_schema_test.js b/libraries/references/test/action_schema_test.js index 4001effc77b..816019165e3 100644 --- a/libraries/references/test/action_schema_test.js +++ b/libraries/references/test/action_schema_test.js @@ -1,8 +1,9 @@ const {getCommonSchemas} = require('../src/common-schemas'); const libUrls = require('taskcluster-lib-urls'); const References = require('..'); +const testing = require('taskcluster-lib-testing'); -suite('action_schema_test.js', function() { +suite(testing.suiteName(), function() { const rootUrl = libUrls.testRootUrl(); const references = new References({ diff --git a/libraries/references/test/built-services_test.js b/libraries/references/test/built-services_test.js index eaa23e20807..4a037b54341 100644 --- a/libraries/references/test/built-services_test.js +++ b/libraries/references/test/built-services_test.js @@ -2,8 +2,9 @@ const assert = require('assert'); const {load} = require('../src/built-services'); const mockFs = require('mock-fs'); const References = require('..'); +const testing = require('taskcluster-lib-testing'); -suite('built-services_test.js', function() { +suite(testing.suiteName(), function() { teardown(function() { mockFs.restore(); }); diff --git a/libraries/references/test/common-schemas_test.js b/libraries/references/test/common-schemas_test.js index 25c0b2116b8..89786a53720 100644 --- a/libraries/references/test/common-schemas_test.js +++ b/libraries/references/test/common-schemas_test.js @@ -1,7 +1,8 @@ const assert = require('assert'); const {getCommonSchemas} = require('../src/common-schemas'); +const testing = require('taskcluster-lib-testing'); -suite('common-schemas_test.js', function() { +suite(testing.suiteName(), function() { test('loads common schemas', function() { const schemas = getCommonSchemas(); assert(schemas.some( diff --git a/libraries/references/test/metaschema_test.js b/libraries/references/test/metaschema_test.js index 28e403be3db..8b945de7cf7 100644 --- a/libraries/references/test/metaschema_test.js +++ b/libraries/references/test/metaschema_test.js @@ -1,8 +1,9 @@ const {getCommonSchemas} = require('../src/common-schemas'); const References = require('..'); const libUrls = require('taskcluster-lib-urls'); +const testing = require('taskcluster-lib-testing'); -suite('metaschema_test.js', function() { +suite(testing.suiteName(), function() { let validate; suiteSetup('setup Ajv', function() { diff --git a/libraries/references/test/references_test.js b/libraries/references/test/references_test.js index 71194ae1e42..6c41328ed3c 100644 --- a/libraries/references/test/references_test.js +++ b/libraries/references/test/references_test.js @@ -4,8 +4,9 @@ const {getCommonSchemas} = require('../src/common-schemas'); const {makeSerializable} = require('../src/serializable'); const mockFs = require('mock-fs'); const References = require('..'); +const testing = require('taskcluster-lib-testing'); -suite('references_test.js', function() { +suite(testing.suiteName(), function() { teardown(function() { mockFs.restore(); }); diff --git a/libraries/references/test/serializable_test.js b/libraries/references/test/serializable_test.js index cab5cfa3c07..45f8e05d9ba 100644 --- a/libraries/references/test/serializable_test.js +++ b/libraries/references/test/serializable_test.js @@ -3,8 +3,9 @@ const References = require('..'); const {makeSerializable} = require('../src/serializable'); const {getCommonSchemas} = require('../src/common-schemas'); const libUrls = require('taskcluster-lib-urls'); +const testing = require('taskcluster-lib-testing'); -suite('serializable_test.js', function() { +suite(testing.suiteName(), function() { const rootUrl = libUrls.testRootUrl(); const legacyRootUrl = 'https://taskcluster.net'; diff --git a/libraries/references/test/uri-structured_test.js b/libraries/references/test/uri-structured_test.js index 82aaf223aa8..e881aead710 100644 --- a/libraries/references/test/uri-structured_test.js +++ b/libraries/references/test/uri-structured_test.js @@ -3,8 +3,9 @@ const assert = require('assert'); const References = require('..'); const {readUriStructured, writeUriStructured} = require('../src/uri-structured'); const mockFs = require('mock-fs'); +const testing = require('taskcluster-lib-testing'); -suite('uri-structured_test.js', function() { +suite(testing.suiteName(), function() { teardown(function() { mockFs.restore(); }); diff --git a/libraries/references/test/validate_test.js b/libraries/references/test/validate_test.js index 3cde4061bb9..ab135bd4f6d 100644 --- a/libraries/references/test/validate_test.js +++ b/libraries/references/test/validate_test.js @@ -5,6 +5,7 @@ const merge = require('lodash/merge'); const omit = require('lodash/omit'); const References = require('..'); const {validate} = require('../src/validate'); +const testing = require('taskcluster-lib-testing'); class RefBuilder { constructor() { @@ -76,7 +77,7 @@ class RefBuilder { } } -suite('validate_test.js', function() { +suite(testing.suiteName(), function() { const assertProblems = (references, expected) => { try { validate(references); diff --git a/libraries/scopes/test/expression_test.js b/libraries/scopes/test/expression_test.js index cdcc9f881a7..d8757026319 100644 --- a/libraries/scopes/test/expression_test.js +++ b/libraries/scopes/test/expression_test.js @@ -1,131 +1,134 @@ const assert = require('assert'); const utils = require('../src/expressions.js'); +const testing = require('taskcluster-lib-testing'); -suite('scope expression validity:', function() { +suite(testing.suiteName(), function() { + suite('scope expression validity:', function() { - function scenario(expr, shouldFail=false) { - return () => { - try { - assert(utils.validExpression(expr)); - } catch (err) { + function scenario(expr, shouldFail=false) { + return () => { + try { + assert(utils.validExpression(expr)); + } catch (err) { + if (shouldFail) { + return; + } + throw err; + } if (shouldFail) { - return; + throw new Error('Should have failed!'); } - throw err; - } - if (shouldFail) { - throw new Error('Should have failed!'); - } - }; - } + }; + } - // All of the following are invalid - test('empty is not OK', scenario({}, 'should-fail')); - test('array is not OK', scenario([], 'should-fail')); - test('int is not OK', scenario(12, 'should-fail')); - test('wrong key is not OK', scenario({Foo: ['abc']}, 'should-fail')); - test('multiple keys is not OK', scenario({AnyOf: ['abc'], AllOf: ['abc']}, 'should-fail')); - test('int value is not OK', scenario({AnyOf: 1}, 'should-fail')); - test('string value is not OK', scenario({AnyOf: 'scope:bar'}, 'should-fail')); - test('object value is not OK', scenario({AnyOf: {}}, 'should-fail')); + // All of the following are invalid + test('empty is not OK', scenario({}, 'should-fail')); + test('array is not OK', scenario([], 'should-fail')); + test('int is not OK', scenario(12, 'should-fail')); + test('wrong key is not OK', scenario({Foo: ['abc']}, 'should-fail')); + test('multiple keys is not OK', scenario({AnyOf: ['abc'], AllOf: ['abc']}, 'should-fail')); + test('int value is not OK', scenario({AnyOf: 1}, 'should-fail')); + test('string value is not OK', scenario({AnyOf: 'scope:bar'}, 'should-fail')); + test('object value is not OK', scenario({AnyOf: {}}, 'should-fail')); - // All of the following should be valid - [ - 'hello-world', - 'scope:foo', - {AnyOf: []}, - {AllOf: []}, - {AnyOf: ['abc']}, - {AllOf: ['abc']}, - {AnyOf: [{AnyOf: ['scope:foo:thing']}]}, - {AllOf: [{AllOf: ['scope:foo:thing', 'scope:bar:thing']}]}, - {AnyOf: [{AllOf: ['scope:foo:thing']}]}, - {AllOf: [{AnyOf: ['scope:foo:thing', 'scope:bar:thing']}]}, - {AllOf: [{AnyOf: [{AllOf: ['foo']}, {AllOf: ['bar']}]}]}, - ].forEach(c => { - test(`${JSON.stringify(c)} is OK`, scenario(c)); + // All of the following should be valid + [ + 'hello-world', + 'scope:foo', + {AnyOf: []}, + {AllOf: []}, + {AnyOf: ['abc']}, + {AllOf: ['abc']}, + {AnyOf: [{AnyOf: ['scope:foo:thing']}]}, + {AllOf: [{AllOf: ['scope:foo:thing', 'scope:bar:thing']}]}, + {AnyOf: [{AllOf: ['scope:foo:thing']}]}, + {AllOf: [{AnyOf: ['scope:foo:thing', 'scope:bar:thing']}]}, + {AllOf: [{AnyOf: [{AllOf: ['foo']}, {AllOf: ['bar']}]}]}, + ].forEach(c => { + test(`${JSON.stringify(c)} is OK`, scenario(c)); + }); }); -}); -suite('scope expression satisfaction:', function() { + suite('scope expression satisfaction:', function() { - function scenario(scopes, expr, shouldFail=false) { - return () => { - try { - assert(utils.satisfiesExpression(scopes, expr)); - } catch (err) { + function scenario(scopes, expr, shouldFail=false) { + return () => { + try { + assert(utils.satisfiesExpression(scopes, expr)); + } catch (err) { + if (shouldFail) { + return; + } + throw err; + } if (shouldFail) { - return; + throw new Error('Should have failed!'); } - throw err; - } - if (shouldFail) { - throw new Error('Should have failed!'); - } - }; - } + }; + } - // The following should _not_ succeed - [ - [[], {AnyOf: []}], - [[], 'missing-scope'], - [['wrong-scope'], 'missing-scope'], - [['ghi'], {AnyOf: ['abc', 'def']}], - [['ghi*'], {AnyOf: ['abc', 'def']}], - [['ghi', 'fff'], {AnyOf: ['abc', 'def']}], - [['ghi*', 'fff*'], {AnyOf: ['abc', 'def']}], - [['abc'], {AnyOf: ['ghi']}], - [['abc*'], {AllOf: ['abc', 'ghi']}], - [[''], {AnyOf: ['abc', 'def']}], - [['abc:def'], {AnyOf: ['abc', 'def']}], - [['xyz', 'abc'], {AllOf: [{AnyOf: [{AllOf: ['foo']}, {AllOf: ['bar']}]}]}], - ].forEach(([s, e]) => { - test(`${JSON.stringify(e)} is _not_ satisfied by ${JSON.stringify(s)}`, scenario(s, e, 'should-fail')); - }); + // The following should _not_ succeed + [ + [[], {AnyOf: []}], + [[], 'missing-scope'], + [['wrong-scope'], 'missing-scope'], + [['ghi'], {AnyOf: ['abc', 'def']}], + [['ghi*'], {AnyOf: ['abc', 'def']}], + [['ghi', 'fff'], {AnyOf: ['abc', 'def']}], + [['ghi*', 'fff*'], {AnyOf: ['abc', 'def']}], + [['abc'], {AnyOf: ['ghi']}], + [['abc*'], {AllOf: ['abc', 'ghi']}], + [[''], {AnyOf: ['abc', 'def']}], + [['abc:def'], {AnyOf: ['abc', 'def']}], + [['xyz', 'abc'], {AllOf: [{AnyOf: [{AllOf: ['foo']}, {AllOf: ['bar']}]}]}], + ].forEach(([s, e]) => { + test(`${JSON.stringify(e)} is _not_ satisfied by ${JSON.stringify(s)}`, scenario(s, e, 'should-fail')); + }); - // The following should succeed - [ - [[], {AllOf: []}], - [['A'], {AllOf: ['A']}], - [['A', 'B'], 'A'], - [['abc'], {AnyOf: ['abc', 'def']}], - [['def'], {AnyOf: ['abc', 'def']}], - [['abc', 'def'], {AnyOf: ['abc', 'def']}], - [['abc*'], {AnyOf: ['abc', 'def']}], - [['abc*'], {AnyOf: ['abc']}], - [['abc*', 'def*'], {AnyOf: ['abc', 'def']}], - [['foo'], {AllOf: [{AnyOf: [{AllOf: ['foo']}, {AllOf: ['bar']}]}]}], - ].forEach(([s, e]) => { - test(`${JSON.stringify(e)} is satisfied by ${JSON.stringify(s)}`, scenario(s, e)); - }); + // The following should succeed + [ + [[], {AllOf: []}], + [['A'], {AllOf: ['A']}], + [['A', 'B'], 'A'], + [['abc'], {AnyOf: ['abc', 'def']}], + [['def'], {AnyOf: ['abc', 'def']}], + [['abc', 'def'], {AnyOf: ['abc', 'def']}], + [['abc*'], {AnyOf: ['abc', 'def']}], + [['abc*'], {AnyOf: ['abc']}], + [['abc*', 'def*'], {AnyOf: ['abc', 'def']}], + [['foo'], {AllOf: [{AnyOf: [{AllOf: ['foo']}, {AllOf: ['bar']}]}]}], + ].forEach(([s, e]) => { + test(`${JSON.stringify(e)} is satisfied by ${JSON.stringify(s)}`, scenario(s, e)); + }); -}); + }); -suite('scope expression failure explanation:', function() { + suite('scope expression failure explanation:', function() { - function scenario(scopes, expr, explanation) { - return () => { - assert.deepEqual(explanation, utils.removeGivenScopes(scopes, expr)); - }; - } + function scenario(scopes, expr, explanation) { + return () => { + assert.deepEqual(explanation, utils.removeGivenScopes(scopes, expr)); + }; + } - [ - [[], {AllOf: []}, null], - [['a'], {AllOf: ['a']}, null], - [['a'], {AllOf: ['a', 'b']}, 'b'], - [[], {AnyOf: []}, {AnyOf: []}], - [['a'], {AnyOf: ['a', 'b']}, null], - [['c'], {AnyOf: ['a', 'b']}, {AnyOf: ['a', 'b']}], - [['ghi'], {AnyOf: ['abc', 'def']}, {AnyOf: ['abc', 'def']}], - [['ghi'], {AllOf: ['abc', 'def', 'ghi']}, {AllOf: ['abc', 'def']}], - [['ghi*', 'fff*'], {AnyOf: ['abc', 'def']}, {AnyOf: ['abc', 'def']}], [ - ['xyz', 'abc'], - {AllOf: [{AnyOf: [{AllOf: ['foo']}, {AllOf: ['bar']}]}]}, - {AnyOf: ['foo', 'bar']}, - ], - ].forEach(([s, e, expl]) => { - test(`Given ${JSON.stringify(s)}, ${JSON.stringify(e)} is explained by ${JSON.stringify(expl)}}`, - scenario(s, e, expl)); + [[], {AllOf: []}, null], + [['a'], {AllOf: ['a']}, null], + [['a'], {AllOf: ['a', 'b']}, 'b'], + [[], {AnyOf: []}, {AnyOf: []}], + [['a'], {AnyOf: ['a', 'b']}, null], + [['c'], {AnyOf: ['a', 'b']}, {AnyOf: ['a', 'b']}], + [['ghi'], {AnyOf: ['abc', 'def']}, {AnyOf: ['abc', 'def']}], + [['ghi'], {AllOf: ['abc', 'def', 'ghi']}, {AllOf: ['abc', 'def']}], + [['ghi*', 'fff*'], {AnyOf: ['abc', 'def']}, {AnyOf: ['abc', 'def']}], + [ + ['xyz', 'abc'], + {AllOf: [{AnyOf: [{AllOf: ['foo']}, {AllOf: ['bar']}]}]}, + {AnyOf: ['foo', 'bar']}, + ], + ].forEach(([s, e, expl]) => { + test(`Given ${JSON.stringify(s)}, ${JSON.stringify(e)} is explained by ${JSON.stringify(expl)}}`, + scenario(s, e, expl)); + }); }); }); diff --git a/libraries/scopes/test/normalize_test.js b/libraries/scopes/test/normalize_test.js index bd60564cd0e..0ed495798cb 100644 --- a/libraries/scopes/test/normalize_test.js +++ b/libraries/scopes/test/normalize_test.js @@ -1,8 +1,9 @@ -suite('normalize', () => { - const utils = require('../src'); - const assert = require('assert'); - const _ = require('lodash'); +const utils = require('../src'); +const assert = require('assert'); +const _ = require('lodash'); +const testing = require('taskcluster-lib-testing'); +suite(testing.suiteName(), () => { suite('scope comparing', function() { const cmp = (a, b) => { if (a < b) { diff --git a/libraries/scopes/test/satsifaction_test.js b/libraries/scopes/test/satsifaction_test.js index daf059e268f..d1fbe45b968 100644 --- a/libraries/scopes/test/satsifaction_test.js +++ b/libraries/scopes/test/satsifaction_test.js @@ -1,7 +1,8 @@ const assert = require('assert'); const utils = require('../src'); +const testing = require('taskcluster-lib-testing'); -suite('satisfaction', function() { +suite(testing.suiteName(), function() { let mktest = function(scopePatterns, scopesets, matches) { return function() { diff --git a/libraries/scopes/test/sets_test.js b/libraries/scopes/test/sets_test.js index 059e9b66d88..c0a438afbb3 100644 --- a/libraries/scopes/test/sets_test.js +++ b/libraries/scopes/test/sets_test.js @@ -1,7 +1,8 @@ const assert = require('assert'); const utils = require('../src'); +const testing = require('taskcluster-lib-testing'); -suite('sets', function() { +suite(testing.suiteName(), function() { suite('scopeUnion', () => { const testScopeUnion = (scope1, scope2, expected, message) => { assert.deepEqual(utils.scopeUnion(scope1, scope2).sort(), expected.sort(), message); diff --git a/libraries/scopes/test/validate_test.js b/libraries/scopes/test/validate_test.js index 553bdd66e99..c8b2586859d 100644 --- a/libraries/scopes/test/validate_test.js +++ b/libraries/scopes/test/validate_test.js @@ -1,7 +1,8 @@ const assert = require('assert'); const utils = require('../src'); +const testing = require('taskcluster-lib-testing'); -suite('validate', function() { +suite(testing.suiteName(), function() { test('Normal-looking scopes are OK', function() { assert(utils.validScope('auth:credentials')); }); diff --git a/libraries/testing/src/suite-name.js b/libraries/testing/src/suite-name.js new file mode 100644 index 00000000000..d8e02a3a64c --- /dev/null +++ b/libraries/testing/src/suite-name.js @@ -0,0 +1,10 @@ +const errorStackParser = require('error-stack-parser'); +const path = require('path'); + +const ROOT_DIR = path.resolve(__dirname, '../../..'); const suiteName = () => { + const o = {}; Error.captureStackTrace(o, suiteName); + const stack = errorStackParser.parse(o); + return path.relative(ROOT_DIR, stack[0].fileName); +}; + +module.exports = suiteName; diff --git a/libraries/testing/src/testing.js b/libraries/testing/src/testing.js index 97b73bc5fb8..9d73a6ebaef 100644 --- a/libraries/testing/src/testing.js +++ b/libraries/testing/src/testing.js @@ -6,6 +6,7 @@ exports.Secrets = require('./secrets'); exports.poll = require('./poll'); exports.sleep = require('./sleep'); exports.withEntity = require('./with-entity'); +exports.suiteName = require('./suite-name'); exports.createMockAuthServer = () => { throw new Error('No longer available; use fakeauth instead'); diff --git a/libraries/testing/test/fakeauth_test.js b/libraries/testing/test/fakeauth_test.js index 4e915f32433..ba8f5a98dce 100644 --- a/libraries/testing/test/fakeauth_test.js +++ b/libraries/testing/test/fakeauth_test.js @@ -10,6 +10,7 @@ const taskcluster = require('taskcluster-client'); const Promise = require('promise'); const path = require('path'); const libUrls = require('taskcluster-lib-urls'); +const testing = require('taskcluster-lib-testing'); const builder = new APIBuilder({ title: 'Test Server', @@ -37,9 +38,9 @@ builder.declare({ } }); -suite('fakeauth', function() { +suite(testing.suiteName(), function() { const rootUrl = 'http://localhost:1208'; - let fakeauth = require('../src/fakeauth'); + let fakeauth = testing.fakeauth; let server; suiteSetup(async function() { diff --git a/libraries/testing/test/schemas_test.js b/libraries/testing/test/schemas_test.js index 1b06306136e..3185233f15c 100644 --- a/libraries/testing/test/schemas_test.js +++ b/libraries/testing/test/schemas_test.js @@ -1,8 +1,8 @@ -const libTesting = require('../'); const path = require('path'); +const testing = require('taskcluster-lib-testing'); -suite('testing.schema', function() { - libTesting.schemas({ +suite(testing.suiteName(), function() { + testing.schemas({ schemasetOptions: { folder: path.join(__dirname, 'schemas'), serviceName: 'test', diff --git a/libraries/testing/test/secrets_test.js b/libraries/testing/test/secrets_test.js index 448313dcc47..929ecd9925c 100644 --- a/libraries/testing/test/secrets_test.js +++ b/libraries/testing/test/secrets_test.js @@ -1,9 +1,9 @@ -const {Secrets, stickyLoader} = require('../'); +const {Secrets, stickyLoader, suiteName} = require('../'); const _ = require('lodash'); const assert = require('assert'); const nock = require('nock'); -suite('Secrets', function() { +suite(suiteName(), function() { let oldTaskId; let savedEnv; diff --git a/libraries/testing/test/stickyloader_test.js b/libraries/testing/test/stickyloader_test.js index 4d1d54e6ca3..c8e725e84e4 100644 --- a/libraries/testing/test/stickyloader_test.js +++ b/libraries/testing/test/stickyloader_test.js @@ -1,8 +1,8 @@ const _ = require('lodash'); const assert = require('assert'); -const {stickyLoader} = require('../'); +const {stickyLoader, suiteName} = require('../'); -suite('stickyLoader', function() { +suite(suiteName(), function() { let loads, sticky; const loader = (component, overwrites) => { diff --git a/libraries/testing/test/utils_test.js b/libraries/testing/test/utils_test.js index 89d28e858af..13dd5c46bbe 100644 --- a/libraries/testing/test/utils_test.js +++ b/libraries/testing/test/utils_test.js @@ -1,10 +1,10 @@ -const libTesting = require('../'); const assert = require('assert'); +const testing = require('taskcluster-lib-testing'); -suite('testing (utilities)', function() { +suite(testing.suiteName(), function() { test('sleep', async function() { const start = new Date().getTime(); - await libTesting.sleep(10); + await testing.sleep(10); const end = new Date().getTime(); // as long as it waited 5ms or more we'll call it good.. assert(end - start > 5, 'did not wait long enough'); @@ -14,7 +14,7 @@ suite('testing (utilities)', function() { const pollFunc = () => { countDown = 5; return async () => { - await libTesting.sleep(1); + await testing.sleep(1); countDown -= 1; if (countDown === 0) { return 'success'; @@ -25,14 +25,14 @@ suite('testing (utilities)', function() { test('poll (success)', async function() { const poll = pollFunc(); - await libTesting.poll(poll, 4, 5); + await testing.poll(poll, 4, 5); assert.equal(countDown, 0); }); test('poll (too-few iterations)', async function() { const poll = pollFunc(); try { - await libTesting.poll(poll, 3, 5); + await testing.poll(poll, 3, 5); } catch (err) { if (!/Something bad/.test(err)) { throw err; diff --git a/libraries/validate/test/debugging_test.js b/libraries/validate/test/debugging_test.js index f918f5d6aac..5e68d340c9a 100644 --- a/libraries/validate/test/debugging_test.js +++ b/libraries/validate/test/debugging_test.js @@ -1,11 +1,12 @@ -suite('Debugging Tests', () => { - let assert = require('assert'); - let SchemaSet = require('../'); - let rimraf = require('rimraf'); - let fs = require('fs'); - let intercept = require('intercept-stdout'); - let libUrls = require('taskcluster-lib-urls'); +const assert = require('assert'); +const SchemaSet = require('../'); +const rimraf = require('rimraf'); +const fs = require('fs'); +const intercept = require('intercept-stdout'); +const libUrls = require('taskcluster-lib-urls'); +const testing = require('taskcluster-lib-testing'); +suite(testing.suiteName(), () => { test('preview previews', async function() { let stdout = ''; const unhook = intercept(txt => { diff --git a/libraries/validate/test/publish_test.js b/libraries/validate/test/publish_test.js index 87c2ae6590f..dd5d5845a05 100644 --- a/libraries/validate/test/publish_test.js +++ b/libraries/validate/test/publish_test.js @@ -1,12 +1,13 @@ -suite('Publish Tests', () => { - let SchemaSet = require('../'); - let awsMock = require('mock-aws-s3'); - let os = require('os'); - let path = require('path'); - let rimraf = require('rimraf'); - let debug = require('debug')('test'); - let libUrls = require('taskcluster-lib-urls'); +const SchemaSet = require('../'); +const awsMock = require('mock-aws-s3'); +const os = require('os'); +const path = require('path'); +const rimraf = require('rimraf'); +const debug = require('debug')('test'); +const libUrls = require('taskcluster-lib-urls'); +const testing = require('taskcluster-lib-testing'); +suite(testing.suiteName(), () => { let s3 = null; let mockdir = path.join(os.tmpdir(), 'tc-lib-validate', 'buckets'); diff --git a/libraries/validate/test/schemaset_test.js b/libraries/validate/test/schemaset_test.js index 9ef1aa296ca..67a4326a4fc 100644 --- a/libraries/validate/test/schemaset_test.js +++ b/libraries/validate/test/schemaset_test.js @@ -2,8 +2,9 @@ const assert = require('assert'); const SchemaSet = require('../'); const _ = require('lodash'); const libUrls = require('taskcluster-lib-urls'); +const testing = require('taskcluster-lib-testing'); -suite('schemaset_test.js', () => { +suite(testing.suiteName(), () => { const rootUrl = libUrls.testRootUrl(); const makeSchemaSet = () => { diff --git a/libraries/validate/test/util_test.js b/libraries/validate/test/util_test.js index d3aad67a82a..83496f7f001 100644 --- a/libraries/validate/test/util_test.js +++ b/libraries/validate/test/util_test.js @@ -1,7 +1,8 @@ const assert = require('assert'); const {checkRefs} = require('../src/util'); +const testing = require('taskcluster-lib-testing'); -suite('test_util.js', function() { +suite(testing.suiteName(), function() { suite('checkRefs', function() { // include some arrays and objects to test the "deepness" of the check const schemaWith = innards => ({ diff --git a/libraries/validate/test/validate_test.js b/libraries/validate/test/validate_test.js index cf71088c608..bb66647ae40 100644 --- a/libraries/validate/test/validate_test.js +++ b/libraries/validate/test/validate_test.js @@ -1,9 +1,10 @@ -suite('Valid Schema Tests', () => { - const assert = require('assert'); - const SchemaSet = require('../'); - const debug = require('debug')('test'); - const libUrls = require('taskcluster-lib-urls'); +const assert = require('assert'); +const SchemaSet = require('../'); +const debug = require('debug')('test'); +const libUrls = require('taskcluster-lib-urls'); +const testing = require('taskcluster-lib-testing'); +suite(testing.suiteName(), () => { const rootUrl = libUrls.testRootUrl(); let validate = null; diff --git a/package.json b/package.json index b223b7c21a6..80a1eb177d0 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "dockerode": "^2.5.8", "dot": "^1.1.2", "ejs": "^2.6.1", + "error-stack-parser": "^2.0.2", "eslint": "5.16.0", "fs-extra": "^7.0.1", "glob": "^7.1.3", diff --git a/services/auth/test/azure_test.js b/services/auth/test/azure_test.js index c3cd3da7562..4317d906a32 100644 --- a/services/auth/test/azure_test.js +++ b/services/auth/test/azure_test.js @@ -3,8 +3,9 @@ const helper = require('./helper'); const _ = require('lodash'); const azure = require('fast-azure-storage'); const taskcluster = require('taskcluster-client'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(helper.suiteName(__filename), ['app', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['app', 'azure'], function(mock, skipping) { if (mock) { return; // We only test this with real creds } diff --git a/services/auth/test/client_test.js b/services/auth/test/client_test.js index e55a76c961e..ab72fc462ff 100644 --- a/services/auth/test/client_test.js +++ b/services/auth/test/client_test.js @@ -5,7 +5,7 @@ const assume = require('assume'); const testing = require('taskcluster-lib-testing'); const taskcluster = require('taskcluster-client'); -helper.secrets.mockSuite(helper.suiteName(__filename), ['app', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['app', 'azure'], function(mock, skipping) { helper.withPulse(mock, skipping); helper.withEntities(mock, skipping); helper.withRoles(mock, skipping); diff --git a/services/auth/test/containers_test.js b/services/auth/test/containers_test.js index f750a7c500f..975c2d16dc0 100644 --- a/services/auth/test/containers_test.js +++ b/services/auth/test/containers_test.js @@ -3,13 +3,14 @@ const uuid = require('uuid'); const assert = require('assert'); const helper = require('./helper'); const azure = require('fast-azure-storage'); +const testing = require('taskcluster-lib-testing'); const sorted = (arr) => { arr.sort(); return arr; }; -helper.secrets.mockSuite(helper.suiteName(__filename), ['azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['azure'], function(mock, skipping) { if (mock) { return; // This test file only works on real things apparently } diff --git a/services/auth/test/helper.js b/services/auth/test/helper.js index 66dfd1e8f4e..1cdbd6ecf5c 100644 --- a/services/auth/test/helper.js +++ b/services/auth/test/helper.js @@ -2,7 +2,6 @@ const debug = require('debug')('test-helper'); const assert = require('assert'); const http = require('http'); const httpProxy = require('http-proxy'); -const path = require('path'); const _ = require('lodash'); const data = require('../src/data'); const builder = require('../src/api'); @@ -17,8 +16,6 @@ const App = require('taskcluster-lib-app'); const {stickyLoader, Secrets, withEntity} = require('taskcluster-lib-testing'); const {FakeClient} = require('taskcluster-lib-pulse'); -exports.suiteName = path.basename; - exports.load = stickyLoader(load); suiteSetup(async function() { diff --git a/services/auth/test/purgeExpiredClients_test.js b/services/auth/test/purgeExpiredClients_test.js index 8df733701ad..9d1adbaa240 100644 --- a/services/auth/test/purgeExpiredClients_test.js +++ b/services/auth/test/purgeExpiredClients_test.js @@ -1,8 +1,9 @@ const helper = require('./helper'); const assume = require('assume'); const taskcluster = require('taskcluster-client'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(helper.suiteName(__filename), ['app', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['app', 'azure'], function(mock, skipping) { helper.withPulse(mock, skipping); helper.withEntities(mock, skipping); helper.withRoles(mock, skipping); diff --git a/services/auth/test/references_test.js b/services/auth/test/references_test.js index 93de192f443..e06e221d42d 100644 --- a/services/auth/test/references_test.js +++ b/services/auth/test/references_test.js @@ -2,8 +2,9 @@ const builder = require('../src/api'); const exchanges = require('../src/exchanges'); const helper = require('./helper'); const References = require('taskcluster-lib-references'); +const testing = require('taskcluster-lib-testing'); -suite('references_test.js', function() { +suite(testing.suiteName(), function() { test('references validate', async function() { const schemaset = await helper.load('schemaset'); const references = References.fromService({schemaset, builder, exchanges}); diff --git a/services/auth/test/remotevalidation_test.js b/services/auth/test/remotevalidation_test.js index 6454cbfc04a..7d7cb03eacc 100644 --- a/services/auth/test/remotevalidation_test.js +++ b/services/auth/test/remotevalidation_test.js @@ -3,8 +3,9 @@ const helper = require('./helper'); const slugid = require('slugid'); const taskcluster = require('taskcluster-client'); const request = require('superagent'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(helper.suiteName(__filename), ['app', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['app', 'azure'], function(mock, skipping) { helper.withPulse(mock, skipping); helper.withEntities(mock, skipping); helper.withRoles(mock, skipping); diff --git a/services/auth/test/role_test.js b/services/auth/test/role_test.js index ca96e83e940..6b85557b273 100644 --- a/services/auth/test/role_test.js +++ b/services/auth/test/role_test.js @@ -6,7 +6,7 @@ const assume = require('assume'); const testing = require('taskcluster-lib-testing'); const taskcluster = require('taskcluster-client'); -helper.secrets.mockSuite(helper.suiteName(__filename), ['app', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['app', 'azure'], function(mock, skipping) { helper.withPulse(mock, skipping); helper.withEntities(mock, skipping, {orderedTests: true}); helper.withRoles(mock, skipping, {orderedTests: true}); diff --git a/services/auth/test/rolelogic_test.js b/services/auth/test/rolelogic_test.js index 849fe28e1fd..84add7c76b1 100644 --- a/services/auth/test/rolelogic_test.js +++ b/services/auth/test/rolelogic_test.js @@ -2,8 +2,9 @@ const helper = require('./helper'); const _ = require('lodash'); const taskcluster = require('taskcluster-client'); const mocha = require('mocha'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(helper.suiteName(__filename), ['app', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['app', 'azure'], function(mock, skipping) { helper.withPulse(mock, skipping); helper.withEntities(mock, skipping); helper.withRoles(mock, skipping); diff --git a/services/auth/test/s3_test.js b/services/auth/test/s3_test.js index 3d8c5aa63a7..7764dbe4020 100644 --- a/services/auth/test/s3_test.js +++ b/services/auth/test/s3_test.js @@ -3,8 +3,9 @@ const slugid = require('slugid'); const aws = require('aws-sdk'); const helper = require('./helper'); const debug = require('debug')('s3_test'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(helper.suiteName(__filename), ['app', 'aws'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['app', 'aws'], function(mock, skipping) { if (mock) { return; // This is actually testing sts tokens and we are not going to mock those } diff --git a/services/auth/test/scoperesolver_test.js b/services/auth/test/scoperesolver_test.js index 016c2cd68fb..6d15eebeda0 100644 --- a/services/auth/test/scoperesolver_test.js +++ b/services/auth/test/scoperesolver_test.js @@ -6,8 +6,9 @@ const monitorManager = require('../src/monitor'); const assert = require('assert'); const _ = require('lodash'); const assume = require('assume'); +const testing = require('taskcluster-lib-testing'); -suite(helper.suiteName(__filename), () => { +suite(testing.suiteName(), () => { let monitor, scopeResolver; setup(async () => { monitorManager.setup({ diff --git a/services/auth/test/scopesetbuilder_test.js b/services/auth/test/scopesetbuilder_test.js index d5d0d7212f0..833ab28b23b 100644 --- a/services/auth/test/scopesetbuilder_test.js +++ b/services/auth/test/scopesetbuilder_test.js @@ -1,9 +1,10 @@ -suite('ScopeSetBuilder', () => { - const assume = require('assume'); - const _ = require('lodash'); - const {mergeScopeSets, scopeCompare} = require('taskcluster-lib-scopes'); - const ScopeSetBuilder = require('../src/scopesetbuilder'); +const assume = require('assume'); +const _ = require('lodash'); +const {mergeScopeSets, scopeCompare} = require('taskcluster-lib-scopes'); +const ScopeSetBuilder = require('../src/scopesetbuilder'); +const testing = require('taskcluster-lib-testing'); +suite(testing.suiteName(), () => { test('scopes()', () => { assume(new ScopeSetBuilder().scopes()).eql([]); }); diff --git a/services/auth/test/sentry_test.js b/services/auth/test/sentry_test.js index 0018df1a8bd..f853736cc3e 100644 --- a/services/auth/test/sentry_test.js +++ b/services/auth/test/sentry_test.js @@ -1,8 +1,9 @@ const helper = require('./helper'); const taskcluster = require('taskcluster-client'); const assert = require('assert'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(helper.suiteName(__filename), ['app'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['app'], function(mock, skipping) { if (!mock) { return; // We don't test this with real credentials for now! } diff --git a/services/auth/test/signaturevalidator_test.js b/services/auth/test/signaturevalidator_test.js index 9cf54bd8b4b..bbd49fefee0 100644 --- a/services/auth/test/signaturevalidator_test.js +++ b/services/auth/test/signaturevalidator_test.js @@ -1,4 +1,3 @@ -const helper = require('./helper'); const hawk = require('hawk'); const _ = require('lodash'); const assume = require('assume'); @@ -7,8 +6,9 @@ const crypto = require('crypto'); const taskcluster = require('taskcluster-client'); const sigvalidator = require('../src/signaturevalidator'); const monitorManager = require('../src/monitor'); +const testing = require('taskcluster-lib-testing'); -suite(helper.suiteName(__filename), function() { +suite(testing.suiteName(), function() { let one_hour = taskcluster.fromNow('1 hour'); let two_hours = taskcluster.fromNow('2 hour'); let three_hours = taskcluster.fromNow('3 hour'); diff --git a/services/auth/test/staticclients_test.js b/services/auth/test/staticclients_test.js index 38482c41f95..2bb323ff756 100644 --- a/services/auth/test/staticclients_test.js +++ b/services/auth/test/staticclients_test.js @@ -2,8 +2,9 @@ const assert = require('assert'); const debug = require('debug')('test:static-clients'); const helper = require('./helper'); const assume = require('assume'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(helper.suiteName(__filename), ['app', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['app', 'azure'], function(mock, skipping) { helper.withPulse(mock, skipping); helper.withEntities(mock, skipping); helper.withRoles(mock, skipping); diff --git a/services/auth/test/statsum_test.js b/services/auth/test/statsum_test.js index 6cdff4296b5..d367f0e85f0 100644 --- a/services/auth/test/statsum_test.js +++ b/services/auth/test/statsum_test.js @@ -1,7 +1,8 @@ const helper = require('./helper'); const assert = require('assert'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(helper.suiteName(__filename), ['app', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['app', 'azure'], function(mock, skipping) { helper.withPulse(mock, skipping); helper.withEntities(mock, skipping); helper.withRoles(mock, skipping); diff --git a/services/auth/test/stories_test.js b/services/auth/test/stories_test.js index dca55a6a346..38afb194e22 100644 --- a/services/auth/test/stories_test.js +++ b/services/auth/test/stories_test.js @@ -2,8 +2,9 @@ const assert = require('assert'); const helper = require('./helper'); const assume = require('assume'); const taskcluster = require('taskcluster-client'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(helper.suiteName(__filename), ['app', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['app', 'azure'], function(mock, skipping) { helper.withPulse(mock, skipping); helper.withEntities(mock, skipping, {orderedTests: true}); helper.withRoles(mock, skipping, {orderedTests: true}); diff --git a/services/auth/test/testauth_test.js b/services/auth/test/testauth_test.js index 5647972b0f0..caa936058a5 100644 --- a/services/auth/test/testauth_test.js +++ b/services/auth/test/testauth_test.js @@ -1,5 +1,6 @@ const assert = require('assert'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); const credentials = { clientId: 'tester', @@ -11,127 +12,129 @@ const badcreds = { accessToken: 'wrong', }; -helper.secrets.mockSuite(helper.suiteName(__filename), ['app', 'azure'], function(mock, skipping) { - helper.withPulse(mock, skipping); - helper.withEntities(mock, skipping); - helper.withRoles(mock, skipping); - helper.withServers(mock, skipping); - - let testAuth = (name, {config, requiredScopes, clientScopes, errorCode}) => { - test(name, async () => { - let auth = new helper.AuthClient(config); - await auth.testAuthenticate({requiredScopes, clientScopes}).then(() => { - assert(!errorCode, 'Request was successful, but expected an error ' + - 'with code: ' + errorCode); - }, err => { - assert(errorCode, 'Request failed!'); - assert(err.code === errorCode, 'Expected error with code: ' + - errorCode + ' but got: ' + err.code); +suite(testing.suiteName(), function() { + helper.secrets.mockSuite('testAuth', ['app', 'azure'], function(mock, skipping) { + helper.withPulse(mock, skipping); + helper.withEntities(mock, skipping); + helper.withRoles(mock, skipping); + helper.withServers(mock, skipping); + + let testAuth = (name, {config, requiredScopes, clientScopes, errorCode}) => { + test(name, async () => { + let auth = new helper.AuthClient(config); + await auth.testAuthenticate({requiredScopes, clientScopes}).then(() => { + assert(!errorCode, 'Request was successful, but expected an error ' + + 'with code: ' + errorCode); + }, err => { + assert(errorCode, 'Request failed!'); + assert(err.code === errorCode, 'Expected error with code: ' + + errorCode + ' but got: ' + err.code); + }); }); - }); - }; + }; - testAuth('valid creds', { - config: {rootUrl: helper.rootUrl, credentials}, - requiredScopes: ['test-scope:test'], - clientScopes: ['test-scope:test'], - }); + testAuth('valid creds', { + config: {rootUrl: helper.rootUrl, credentials}, + requiredScopes: ['test-scope:test'], + clientScopes: ['test-scope:test'], + }); - testAuth('valid creds (star scope)', { - config: {rootUrl: helper.rootUrl, credentials}, - requiredScopes: ['test-scope:test'], - clientScopes: ['test-scope:*'], - }); + testAuth('valid creds (star scope)', { + config: {rootUrl: helper.rootUrl, credentials}, + requiredScopes: ['test-scope:test'], + clientScopes: ['test-scope:*'], + }); - testAuth('valid creds (scope subset)', { - config: {rootUrl: helper.rootUrl, credentials}, - requiredScopes: ['test-scope:test2'], - clientScopes: ['test-scope:test1', 'test-scope:test2'], - }); + testAuth('valid creds (scope subset)', { + config: {rootUrl: helper.rootUrl, credentials}, + requiredScopes: ['test-scope:test2'], + clientScopes: ['test-scope:test1', 'test-scope:test2'], + }); - testAuth('invalid creds (scope subset)', { - config: {rootUrl: helper.rootUrl, credentials}, - requiredScopes: ['test-scope:test2'], - clientScopes: ['test-scope:test1', 'test-scope:test2'], - }); + testAuth('invalid creds (scope subset)', { + config: {rootUrl: helper.rootUrl, credentials}, + requiredScopes: ['test-scope:test2'], + clientScopes: ['test-scope:test1', 'test-scope:test2'], + }); - testAuth('invalid creds', { - config: {rootUrl: helper.rootUrl, credentials: badcreds}, - requiredScopes: ['test-scope'], - clientScopes: ['test-scope'], - errorCode: 'AuthenticationFailed', - }); + testAuth('invalid creds', { + config: {rootUrl: helper.rootUrl, credentials: badcreds}, + requiredScopes: ['test-scope'], + clientScopes: ['test-scope'], + errorCode: 'AuthenticationFailed', + }); - testAuth('insufficientScopes', { - config: {rootUrl: helper.rootUrl, credentials}, - requiredScopes: ['test-scope:*'], - clientScopes: ['test-scope'], - errorCode: 'InsufficientScopes', - }); + testAuth('insufficientScopes', { + config: {rootUrl: helper.rootUrl, credentials}, + requiredScopes: ['test-scope:*'], + clientScopes: ['test-scope'], + errorCode: 'InsufficientScopes', + }); - testAuth('authorizedScopes', { - config: {rootUrl: helper.rootUrl, credentials, authorizedScopes: ['test-scope:test']}, - requiredScopes: ['test-scope:test'], - clientScopes: ['test-scope:*'], - }); + testAuth('authorizedScopes', { + config: {rootUrl: helper.rootUrl, credentials, authorizedScopes: ['test-scope:test']}, + requiredScopes: ['test-scope:test'], + clientScopes: ['test-scope:*'], + }); - testAuth('authorizedScopes InsufficientScopes', { - config: {rootUrl: helper.rootUrl, credentials, authorizedScopes: ['test-scope:test1']}, - requiredScopes: ['test-scope:test2'], - clientScopes: ['test-scope:*'], - errorCode: 'InsufficientScopes', - }); + testAuth('authorizedScopes InsufficientScopes', { + config: {rootUrl: helper.rootUrl, credentials, authorizedScopes: ['test-scope:test1']}, + requiredScopes: ['test-scope:test2'], + clientScopes: ['test-scope:*'], + errorCode: 'InsufficientScopes', + }); - testAuth('authorizedScopes over-scoped', { - config: {rootUrl: helper.rootUrl, credentials, authorizedScopes: ['test-scope:*']}, - requiredScopes: ['test-scope:test2'], - clientScopes: ['test-scope:test2'], - errorCode: 'AuthenticationFailed', - }); + testAuth('authorizedScopes over-scoped', { + config: {rootUrl: helper.rootUrl, credentials, authorizedScopes: ['test-scope:*']}, + requiredScopes: ['test-scope:test2'], + clientScopes: ['test-scope:test2'], + errorCode: 'AuthenticationFailed', + }); - testAuth('authorizedScopes badcreds', { - config: {rootUrl: helper.rootUrl, credentials: badcreds, authorizedScopes: ['test-scope:test']}, - requiredScopes: ['test-scope:test'], - clientScopes: ['test-scope:*'], - errorCode: 'AuthenticationFailed', + testAuth('authorizedScopes badcreds', { + config: {rootUrl: helper.rootUrl, credentials: badcreds, authorizedScopes: ['test-scope:test']}, + requiredScopes: ['test-scope:test'], + clientScopes: ['test-scope:*'], + errorCode: 'AuthenticationFailed', + }); }); -}); -helper.secrets.mockSuite(`${helper.suiteName(__filename)} | get`, ['app', 'azure'], function(mock, skipping) { - helper.withPulse(mock, skipping); - helper.withEntities(mock, skipping); - helper.withRoles(mock, skipping); - helper.withServers(mock, skipping); - - let testAuthGet = (name, {config, errorCode}) => { - test(name, async () => { - let auth = new helper.AuthClient(config); - await auth.testAuthenticateGet().then(() => { - assert(!errorCode, 'Request was successful, but expected an error ' + - 'with code: ' + errorCode); - }, err => { - assert(errorCode, 'Request failed!'); - assert(err.code === errorCode, 'Expected error with code: ' + - errorCode + ' but got: ' + err.code); + helper.secrets.mockSuite('testAuthGet', ['app', 'azure'], function(mock, skipping) { + helper.withPulse(mock, skipping); + helper.withEntities(mock, skipping); + helper.withRoles(mock, skipping); + helper.withServers(mock, skipping); + + let testAuthGet = (name, {config, errorCode}) => { + test(name, async () => { + let auth = new helper.AuthClient(config); + await auth.testAuthenticateGet().then(() => { + assert(!errorCode, 'Request was successful, but expected an error ' + + 'with code: ' + errorCode); + }, err => { + assert(errorCode, 'Request failed!'); + assert(err.code === errorCode, 'Expected error with code: ' + + errorCode + ' but got: ' + err.code); + }); }); - }); - }; + }; - testAuthGet('valid creds', { - config: {rootUrl: helper.rootUrl, credentials}, - }); + testAuthGet('valid creds', { + config: {rootUrl: helper.rootUrl, credentials}, + }); - testAuthGet('invalid creds', { - config: {rootUrl: helper.rootUrl, credentials: badcreds}, - errorCode: 'AuthenticationFailed', - }); + testAuthGet('invalid creds', { + config: {rootUrl: helper.rootUrl, credentials: badcreds}, + errorCode: 'AuthenticationFailed', + }); - testAuthGet('authorizedScopes', { - config: { - rootUrl: helper.rootUrl, - credentials, - authorizedScopes: ['test:scopes-abc'], - }, - errorCode: 'InsufficientScopes', + testAuthGet('authorizedScopes', { + config: { + rootUrl: helper.rootUrl, + credentials, + authorizedScopes: ['test:scopes-abc'], + }, + errorCode: 'InsufficientScopes', + }); }); }); diff --git a/services/auth/test/trie_test.js b/services/auth/test/trie_test.js index 9e47d0c6c20..994e005a5a5 100644 --- a/services/auth/test/trie_test.js +++ b/services/auth/test/trie_test.js @@ -1,9 +1,9 @@ -const helper = require('./helper'); const assume = require('assume'); const _ = require('lodash'); const ScopeSetBuilder = require('../src/scopesetbuilder'); const trie = require('../src/trie'); const trietestcases = require('./trietestcases'); +const testing = require('taskcluster-lib-testing'); // This test suite was designed to test every conceivable combination of // inputs to the trie implementation, in an effort to suss out any hidden bugs @@ -13,7 +13,7 @@ const trietestcases = require('./trietestcases'); // total test suite, just set FULL_TESTS=1. const FULL_TESTS = !!process.env.FULL_TESTS; -suite(helper.suiteName(__filename), () => { +suite(testing.suiteName(), () => { /** * Return scope without kleene '*' at the end if scope ends with kleene, otherwise diff --git a/services/auth/test/validate_test.js b/services/auth/test/validate_test.js index 714328a41bf..5cc953a43f8 100644 --- a/services/auth/test/validate_test.js +++ b/services/auth/test/validate_test.js @@ -1,4 +1,3 @@ -const helper = require('./helper'); const path = require('path'); const testing = require('taskcluster-lib-testing'); @@ -68,7 +67,7 @@ const testCases = [ }, ]; -suite(helper.suiteName(__filename), function() { +suite(testing.suiteName(), function() { // Run test cases using schemas testing utility from taskcluster-lib-testing testing.schemas({ schemasetOptions: { diff --git a/services/auth/test/websocktunnel_test.js b/services/auth/test/websocktunnel_test.js index d11755a9539..e0400f44496 100644 --- a/services/auth/test/websocktunnel_test.js +++ b/services/auth/test/websocktunnel_test.js @@ -1,8 +1,9 @@ const helper = require('./helper'); const assert = require('assert'); const jwt = require('jsonwebtoken'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(helper.suiteName(__filename), ['app', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['app', 'azure'], function(mock, skipping) { helper.withPulse(mock, skipping); helper.withEntities(mock, skipping); helper.withRoles(mock, skipping); diff --git a/services/built-in-workers/test/index_test.js b/services/built-in-workers/test/index_test.js index 6bd73e0a37f..ad8dc2203d5 100644 --- a/services/built-in-workers/test/index_test.js +++ b/services/built-in-workers/test/index_test.js @@ -1,7 +1,8 @@ const helper = require('./helper'); const slugid = require('slugid'); +const testing = require('taskcluster-lib-testing'); -suite('TaskQueue_test.js', function() { +suite(testing.suiteName(), function() { helper.withFakeQueue(); test('check succeed worker', async function() { diff --git a/services/github/test/api_test.js b/services/github/test/api_test.js index 38c8ddca472..da82d01c0f5 100644 --- a/services/github/test/api_test.js +++ b/services/github/test/api_test.js @@ -2,13 +2,14 @@ const helper = require('./helper'); const assert = require('assert'); const _ = require('lodash'); const got = require('got'); +const testing = require('taskcluster-lib-testing'); /** * Tests of endpoints in the api _other than_ * the github webhook endpoint which is tested * in webhook_test.js */ -helper.secrets.mockSuite('api_test.js', ['taskcluster'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster'], function(mock, skipping) { helper.withEntities(mock, skipping); helper.withFakeGithub(mock, skipping); helper.withServer(mock, skipping); diff --git a/services/github/test/fake_github_test.js b/services/github/test/fake_github_test.js index c34a5edbf40..03875f45462 100644 --- a/services/github/test/fake_github_test.js +++ b/services/github/test/fake_github_test.js @@ -2,8 +2,9 @@ const assert = require('assert'); const _ = require('lodash'); const github = require('@octokit/rest'); const fakeGithubAuth = require('./github-auth'); +const testing = require('taskcluster-lib-testing'); -suite('fake github', function() { +suite(testing.suiteName(), function() { function checkKeys(obj, platonic) { let ours = _.filter(Object.keys(obj), k => !k.startsWith('_')); diff --git a/services/github/test/handler_test.js b/services/github/test/handler_test.js index 914548f4a24..2ccfd097b38 100644 --- a/services/github/test/handler_test.js +++ b/services/github/test/handler_test.js @@ -3,12 +3,13 @@ const helper = require('./helper'); const assert = require('assert'); const sinon = require('sinon'); const libUrls = require('taskcluster-lib-urls'); +const testing = require('taskcluster-lib-testing'); /** * This tests the event handlers, faking out all of the services they * interact with. */ -helper.secrets.mockSuite('handlers', ['taskcluster'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster'], function(mock, skipping) { helper.withEntities(mock, skipping); helper.withFakeGithub(mock, skipping); diff --git a/services/github/test/intree_test.js b/services/github/test/intree_test.js index 98fc7f40a48..d05f2044ff6 100644 --- a/services/github/test/intree_test.js +++ b/services/github/test/intree_test.js @@ -4,8 +4,9 @@ const _ = require('lodash'); const helper = require('./helper'); const libUrls = require('taskcluster-lib-urls'); const yaml = require('js-yaml'); +const testing = require('taskcluster-lib-testing'); -suite('intree config', function() { +suite(testing.suiteName(), function() { let intree; suiteSetup(async function() { diff --git a/services/github/test/pulse_test.js b/services/github/test/pulse_test.js index 6b08a02a67d..fb8484eb4ab 100644 --- a/services/github/test/pulse_test.js +++ b/services/github/test/pulse_test.js @@ -1,8 +1,9 @@ const helper = require('./helper'); const assert = require('assert'); const libUrls = require('taskcluster-lib-urls'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite('pulse', ['taskcluster'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster'], function(mock, skipping) { helper.withEntities(mock, skipping); helper.withFakePublisher(mock, skipping); helper.withFakeGithub(mock, skipping); diff --git a/services/github/test/references_test.js b/services/github/test/references_test.js index 93de192f443..e06e221d42d 100644 --- a/services/github/test/references_test.js +++ b/services/github/test/references_test.js @@ -2,8 +2,9 @@ const builder = require('../src/api'); const exchanges = require('../src/exchanges'); const helper = require('./helper'); const References = require('taskcluster-lib-references'); +const testing = require('taskcluster-lib-testing'); -suite('references_test.js', function() { +suite(testing.suiteName(), function() { test('references validate', async function() { const schemaset = await helper.load('schemaset'); const references = References.fromService({schemaset, builder, exchanges}); diff --git a/services/github/test/sync_test.js b/services/github/test/sync_test.js index 407328b2530..dd55c9f7038 100644 --- a/services/github/test/sync_test.js +++ b/services/github/test/sync_test.js @@ -1,10 +1,11 @@ const helper = require('./helper'); const assert = require('assert'); +const testing = require('taskcluster-lib-testing'); /** * Tests of installation syncing */ -helper.secrets.mockSuite('syncInstallations', ['taskcluster'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster'], function(mock, skipping) { helper.withEntities(mock, skipping); helper.withFakeGithub(mock, skipping); helper.withServer(mock, skipping); diff --git a/services/github/test/tc-yaml_test.js b/services/github/test/tc-yaml_test.js index ff9c40f0f06..f918fbbc697 100644 --- a/services/github/test/tc-yaml_test.js +++ b/services/github/test/tc-yaml_test.js @@ -1,7 +1,8 @@ const TcYaml = require('../src/tc-yaml'); const assume = require('assume'); +const testing = require('taskcluster-lib-testing'); -suite('tc-yaml_test.js', function() { +suite(testing.suiteName(), function() { suite('VersionOne', function() { const tcyaml = TcYaml.instantiate(1); const cfg = { diff --git a/services/github/test/webhook_test.js b/services/github/test/webhook_test.js index 8374496734a..05d73737a1f 100644 --- a/services/github/test/webhook_test.js +++ b/services/github/test/webhook_test.js @@ -1,7 +1,8 @@ const helper = require('./helper'); const assert = require('assert'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite('webhook', ['taskcluster'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster'], function(mock, skipping) { helper.withEntities(mock, skipping); helper.withFakeGithub(mock, skipping); helper.withServer(mock, skipping); diff --git a/services/hooks/test/api_test.js b/services/hooks/test/api_test.js index 6dcc66a0912..f072b707ac5 100644 --- a/services/hooks/test/api_test.js +++ b/services/hooks/test/api_test.js @@ -4,8 +4,9 @@ const assume = require('assume'); const debug = require('debug')('test:api:createhook'); const taskcluster = require('taskcluster-client'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite('api_test.js', ['taskcluster'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster'], function(mock, skipping) { helper.withEntities(mock, skipping); helper.withTaskCreator(mock, skipping); helper.withPulse(mock, skipping); diff --git a/services/hooks/test/expires_test.js b/services/hooks/test/expires_test.js index 4e262e0dea3..9af521cc7d8 100644 --- a/services/hooks/test/expires_test.js +++ b/services/hooks/test/expires_test.js @@ -1,8 +1,9 @@ const helper = require('./helper'); const taskcluster = require('taskcluster-client'); const assume = require('assume'); +const testing = require('taskcluster-lib-testing'); -suite('expires_test', function() { +suite(testing.suiteName(), function() { helper.secrets.mockSuite('expires_test.js', ['taskcluster'], function(mock, skipping) { helper.withEntities(mock, skipping); diff --git a/services/hooks/test/listeners_test.js b/services/hooks/test/listeners_test.js index 1ce2b053d2a..85cf27f3133 100644 --- a/services/hooks/test/listeners_test.js +++ b/services/hooks/test/listeners_test.js @@ -3,8 +3,9 @@ const assume = require('assume'); const taskcluster = require('taskcluster-client'); const sinon = require('sinon'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite('listeners_test.js', ['taskcluster'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster'], function(mock, skipping) { helper.withEntities(mock, skipping); helper.withTaskCreator(mock, skipping); helper.withPulse(mock, skipping); diff --git a/services/hooks/test/references_test.js b/services/hooks/test/references_test.js index 93de192f443..e06e221d42d 100644 --- a/services/hooks/test/references_test.js +++ b/services/hooks/test/references_test.js @@ -2,8 +2,9 @@ const builder = require('../src/api'); const exchanges = require('../src/exchanges'); const helper = require('./helper'); const References = require('taskcluster-lib-references'); +const testing = require('taskcluster-lib-testing'); -suite('references_test.js', function() { +suite(testing.suiteName(), function() { test('references validate', async function() { const schemaset = await helper.load('schemaset'); const references = References.fromService({schemaset, builder, exchanges}); diff --git a/services/hooks/test/schedule_hooks_test.js b/services/hooks/test/schedule_hooks_test.js index e09f3f2f972..3c68e7ac6b5 100644 --- a/services/hooks/test/schedule_hooks_test.js +++ b/services/hooks/test/schedule_hooks_test.js @@ -2,8 +2,9 @@ const assert = require('assert'); const Scheduler = require('../src/scheduler'); const helper = require('./helper'); const libUrls = require('taskcluster-lib-urls'); +const testing = require('taskcluster-lib-testing'); -suite('schedule_hooks_test.js', function() { +suite(testing.suiteName(), function() { suiteSetup(async function() { await helper.secrets.setup(); helper.load.save(); diff --git a/services/hooks/test/scheduler_test.js b/services/hooks/test/scheduler_test.js index e89c0f71c80..4402d9444c6 100644 --- a/services/hooks/test/scheduler_test.js +++ b/services/hooks/test/scheduler_test.js @@ -2,8 +2,9 @@ const _ = require('lodash'); const assume = require('assume'); const helper = require('./helper'); const taskcluster = require('taskcluster-client'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite('scheduler_test.js', ['taskcluster'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster'], function(mock, skipping) { helper.withEntities(mock, skipping); helper.withTaskCreator(mock, skipping); diff --git a/services/hooks/test/taskcreator_test.js b/services/hooks/test/taskcreator_test.js index 9573df63316..9cee7509e80 100644 --- a/services/hooks/test/taskcreator_test.js +++ b/services/hooks/test/taskcreator_test.js @@ -7,8 +7,9 @@ const taskcluster = require('taskcluster-client'); const _ = require('lodash'); const hookDef = require('./test_definition'); const libUrls = require('taskcluster-lib-urls'); +const testing = require('taskcluster-lib-testing'); -suite('taskcreator_test.js', function() { +suite(testing.suiteName(), function() { helper.secrets.mockSuite('TaskCreator', ['taskcluster'], function(mock, skipping) { helper.withEntities(mock, skipping); diff --git a/services/hooks/test/validate_test.js b/services/hooks/test/validate_test.js index c431aa9e1dd..7754c7d1cd3 100644 --- a/services/hooks/test/validate_test.js +++ b/services/hooks/test/validate_test.js @@ -1,7 +1,7 @@ const testing = require('taskcluster-lib-testing'); const path = require('path'); -suite('validate', function() { +suite(testing.suiteName(), function() { testing.schemas({ schemasetOptions: { folder: path.join(__dirname, '..', 'schemas'), diff --git a/services/index/test/api_test.js b/services/index/test/api_test.js index 556aec8be61..1387a292e55 100644 --- a/services/index/test/api_test.js +++ b/services/index/test/api_test.js @@ -6,8 +6,9 @@ const taskcluster = require('taskcluster-client'); const request = require('superagent'); const assume = require('assume'); const libUrls = require('taskcluster-lib-urls'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite('api_test.js', ['taskcluster'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster'], function(mock, skipping) { helper.withEntities(mock, skipping); helper.withFakeQueue(mock, skipping); helper.withPulse(mock, skipping); diff --git a/services/index/test/index_test.js b/services/index/test/index_test.js index cd2426d5846..1cfb331eff5 100644 --- a/services/index/test/index_test.js +++ b/services/index/test/index_test.js @@ -6,7 +6,7 @@ const _ = require('lodash'); const testing = require('taskcluster-lib-testing'); const taskcluster = require('taskcluster-client'); -helper.secrets.mockSuite('index_test.js', ['taskcluster'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster'], function(mock, skipping) { helper.withEntities(mock, skipping); helper.withFakeQueue(mock, skipping); helper.withPulse(mock, skipping); diff --git a/services/index/test/references_test.js b/services/index/test/references_test.js index 8782e721dc9..54112bd4313 100644 --- a/services/index/test/references_test.js +++ b/services/index/test/references_test.js @@ -1,8 +1,9 @@ const builder = require('../src/api'); const helper = require('./helper'); const References = require('taskcluster-lib-references'); +const testing = require('taskcluster-lib-testing'); -suite('references_test.js', function() { +suite(testing.suiteName(), function() { test('references validate', async function() { const schemaset = await helper.load('schemaset'); const references = References.fromService({schemaset, builder}); diff --git a/services/login/test/api_test.js b/services/login/test/api_test.js index 599d32b40df..d6d23a0a88b 100644 --- a/services/login/test/api_test.js +++ b/services/login/test/api_test.js @@ -1,11 +1,10 @@ const libUrls = require('taskcluster-lib-urls'); -require('mocha'); - -suite('API', function() { - let assume = require('assume'); - let helper = require('./helper'); - let request = require('superagent'); +const assume = require('assume'); +const helper = require('./helper'); +const request = require('superagent'); +const testing = require('taskcluster-lib-testing'); +suite(testing.suiteName(), function() { helper.setup(); suite('credentialsFromAccessToken', function() { diff --git a/services/login/test/handlers_mozilla_auth0_test.js b/services/login/test/handlers_mozilla_auth0_test.js index ba85bb9d63a..8fdf1f39780 100644 --- a/services/login/test/handlers_mozilla_auth0_test.js +++ b/services/login/test/handlers_mozilla_auth0_test.js @@ -1,7 +1,8 @@ const assume = require('assume'); const Handler = require('../src/handlers/mozilla-auth0'); +const testing = require('taskcluster-lib-testing'); -suite('handlers/mozilla-auth0', function() { +suite(testing.suiteName(), function() { let handler = new Handler({ name: 'mozilla-auth0', cfg: { diff --git a/services/login/test/references_test.js b/services/login/test/references_test.js index cb8805b85c4..960d86dd32e 100644 --- a/services/login/test/references_test.js +++ b/services/login/test/references_test.js @@ -1,8 +1,9 @@ const builder = require('../src/api'); const helper = require('./helper'); const References = require('taskcluster-lib-references'); +const testing = require('taskcluster-lib-testing'); -suite('references_test.js', function() { +suite(testing.suiteName(), function() { helper.setup(); test('references validate', async function() { diff --git a/services/login/test/utils_test.js b/services/login/test/utils_test.js index c76ee291396..0a1aba2072d 100644 --- a/services/login/test/utils_test.js +++ b/services/login/test/utils_test.js @@ -1,7 +1,8 @@ const assume = require('assume'); const {encode, decode} = require('../src/utils'); +const testing = require('taskcluster-lib-testing'); -suite('utils', function() { +suite(testing.suiteName(), function() { suite('encoding', () => { test('encode does not encode the pipe symbol', () => { const result = encode('ad|Mozilla-LDAP|haali'); diff --git a/services/notify/test/api_test.js b/services/notify/test/api_test.js index be0d188327a..a65de152291 100644 --- a/services/notify/test/api_test.js +++ b/services/notify/test/api_test.js @@ -1,7 +1,8 @@ const assert = require('assert'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(helper.suiteName(__filename), ['taskcluster', 'aws'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster', 'aws'], function(mock, skipping) { helper.withEntities(mock, skipping); helper.withPulse(mock, skipping); helper.withSES(mock, skipping); diff --git a/services/notify/test/handler_test.js b/services/notify/test/handler_test.js index f96bfd9760a..3eee6d75b0d 100644 --- a/services/notify/test/handler_test.js +++ b/services/notify/test/handler_test.js @@ -1,8 +1,9 @@ const _ = require('lodash'); const assert = require('assert'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(helper.suiteName(__filename), ['aws'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['aws'], function(mock, skipping) { helper.withFakeQueue(mock, skipping); helper.withSES(mock, skipping); helper.withPulse(mock, skipping); diff --git a/services/notify/test/ratelimit_test.js b/services/notify/test/ratelimit_test.js index d01a688f945..32caeddd79c 100644 --- a/services/notify/test/ratelimit_test.js +++ b/services/notify/test/ratelimit_test.js @@ -2,9 +2,9 @@ const _ = require('lodash'); const assert = require('assert'); const MockDate = require('mockdate'); const RateLimit = require('../src/ratelimit'); -const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); -suite(helper.suiteName(__filename), function() { +suite(testing.suiteName(), function() { let rateLimit; setup(async function() { diff --git a/services/notify/test/references_test.js b/services/notify/test/references_test.js index beda95845f1..9b140be2fc0 100644 --- a/services/notify/test/references_test.js +++ b/services/notify/test/references_test.js @@ -3,8 +3,9 @@ const exchanges = require('../src/exchanges'); const monitorManager = require('../src/monitor'); const helper = require('./helper'); const References = require('taskcluster-lib-references'); +const testing = require('taskcluster-lib-testing'); -suite('references_test.js', function() { +suite(testing.suiteName(), function() { test('references validate', async function() { const schemaset = await helper.load('schemaset'); const references = References.fromService({schemaset, builder, exchanges, monitorManager}); diff --git a/services/purge-cache/test/expire_test.js b/services/purge-cache/test/expire_test.js index 8bec938ab2d..38eba48bb7b 100644 --- a/services/purge-cache/test/expire_test.js +++ b/services/purge-cache/test/expire_test.js @@ -1,8 +1,9 @@ const helper = require('./helper'); const taskcluster = require('taskcluster-client'); const assume = require('assume'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(helper.suiteName(__filename), ['taskcluster'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster'], function(mock, skipping) { helper.withEntities(mock, skipping); test('expire nothing', async function() { diff --git a/services/purge-cache/test/purgecache_test.js b/services/purge-cache/test/purgecache_test.js index 7f021c84580..aa6287dd0b2 100644 --- a/services/purge-cache/test/purgecache_test.js +++ b/services/purge-cache/test/purgecache_test.js @@ -1,7 +1,8 @@ const helper = require('./helper'); const assume = require('assume'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(helper.suiteName(__filename), ['taskcluster'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster'], function(mock, skipping) { helper.withEntities(mock, skipping); helper.withServer(mock, skipping); diff --git a/services/purge-cache/test/references_test.js b/services/purge-cache/test/references_test.js index 8782e721dc9..54112bd4313 100644 --- a/services/purge-cache/test/references_test.js +++ b/services/purge-cache/test/references_test.js @@ -1,8 +1,9 @@ const builder = require('../src/api'); const helper = require('./helper'); const References = require('taskcluster-lib-references'); +const testing = require('taskcluster-lib-testing'); -suite('references_test.js', function() { +suite(testing.suiteName(), function() { test('references validate', async function() { const schemaset = await helper.load('schemaset'); const references = References.fromService({schemaset, builder}); diff --git a/services/queue/test/artifact_test.js b/services/queue/test/artifact_test.js index 64057ea78a8..902f08e6286 100644 --- a/services/queue/test/artifact_test.js +++ b/services/queue/test/artifact_test.js @@ -17,8 +17,9 @@ const qs = require('querystring'); const urllib = require('url'); const http = require('http'); const https = require('https'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(__filename, ['taskcluster', 'aws', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster', 'aws', 'azure'], function(mock, skipping) { helper.withAmazonIPRanges(mock, skipping); helper.withPulse(mock, skipping); helper.withS3(mock, skipping); diff --git a/services/queue/test/bucket_test.js b/services/queue/test/bucket_test.js index 7fdfc842614..fea0a3bf181 100644 --- a/services/queue/test/bucket_test.js +++ b/services/queue/test/bucket_test.js @@ -4,8 +4,9 @@ const Bucket = require('../src/bucket'); const debug = require('debug')('test:bucket_test'); const request = require('superagent'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(__filename, ['aws'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['aws'], function(mock, skipping) { helper.withS3(mock, skipping); if (mock) { diff --git a/services/queue/test/canceltask_test.js b/services/queue/test/canceltask_test.js index 03ea70233da..8c215ba9a2a 100644 --- a/services/queue/test/canceltask_test.js +++ b/services/queue/test/canceltask_test.js @@ -4,8 +4,9 @@ const slugid = require('slugid'); const taskcluster = require('taskcluster-client'); const assume = require('assume'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(__filename, ['taskcluster', 'aws', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster', 'aws', 'azure'], function(mock, skipping) { helper.withAmazonIPRanges(mock, skipping); helper.withPulse(mock, skipping); helper.withS3(mock, skipping); diff --git a/services/queue/test/claimresolver_test.js b/services/queue/test/claimresolver_test.js index 74aded27d7b..f745b81ac83 100644 --- a/services/queue/test/claimresolver_test.js +++ b/services/queue/test/claimresolver_test.js @@ -5,7 +5,7 @@ const taskcluster = require('taskcluster-client'); const helper = require('./helper'); const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(__filename, ['taskcluster', 'aws', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster', 'aws', 'azure'], function(mock, skipping) { helper.withAmazonIPRanges(mock, skipping); helper.withPollingServices(mock, skipping); helper.withPulse(mock, skipping); diff --git a/services/queue/test/claimtask_test.js b/services/queue/test/claimtask_test.js index 2c2872cd1ad..704696fde66 100644 --- a/services/queue/test/claimtask_test.js +++ b/services/queue/test/claimtask_test.js @@ -5,7 +5,7 @@ const assume = require('assume'); const helper = require('./helper'); const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(__filename, ['taskcluster', 'aws', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster', 'aws', 'azure'], function(mock, skipping) { helper.withAmazonIPRanges(mock, skipping); helper.withPulse(mock, skipping); helper.withS3(mock, skipping); diff --git a/services/queue/test/claimwork_test.js b/services/queue/test/claimwork_test.js index a39e0de2d4c..fe3d41f86e6 100644 --- a/services/queue/test/claimwork_test.js +++ b/services/queue/test/claimwork_test.js @@ -4,8 +4,9 @@ const slugid = require('slugid'); const taskcluster = require('taskcluster-client'); const assume = require('assume'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(__filename, ['taskcluster', 'aws', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster', 'aws', 'azure'], function(mock, skipping) { helper.withAmazonIPRanges(mock, skipping); helper.withPulse(mock, skipping); helper.withS3(mock, skipping); diff --git a/services/queue/test/createtask_test.js b/services/queue/test/createtask_test.js index 82be6fb203d..9367b1dcfa5 100644 --- a/services/queue/test/createtask_test.js +++ b/services/queue/test/createtask_test.js @@ -5,8 +5,9 @@ const _ = require('lodash'); const taskcluster = require('taskcluster-client'); const assume = require('assume'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(__filename, ['taskcluster', 'aws', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster', 'aws', 'azure'], function(mock, skipping) { helper.withAmazonIPRanges(mock, skipping); helper.withS3(mock, skipping); helper.withQueueService(mock, skipping); diff --git a/services/queue/test/deadline_test.js b/services/queue/test/deadline_test.js index 8ca4940364f..96ea49fca36 100644 --- a/services/queue/test/deadline_test.js +++ b/services/queue/test/deadline_test.js @@ -6,7 +6,7 @@ const assume = require('assume'); const helper = require('./helper'); const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(__filename, ['taskcluster', 'aws', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster', 'aws', 'azure'], function(mock, skipping) { helper.withPollingServices(mock, skipping); helper.withAmazonIPRanges(mock, skipping); helper.withS3(mock, skipping); diff --git a/services/queue/test/dependency_test.js b/services/queue/test/dependency_test.js index ec1e2240445..b3c9ede7759 100644 --- a/services/queue/test/dependency_test.js +++ b/services/queue/test/dependency_test.js @@ -7,7 +7,7 @@ const testing = require('taskcluster-lib-testing'); const assume = require('assume'); const helper = require('./helper'); -helper.secrets.mockSuite(__filename, ['taskcluster', 'aws', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster', 'aws', 'azure'], function(mock, skipping) { helper.withAmazonIPRanges(mock, skipping); helper.withPollingServices(mock, skipping); helper.withPulse(mock, skipping); diff --git a/services/queue/test/expirequeues_test.js b/services/queue/test/expirequeues_test.js index ade89267a5b..ae23a557fed 100644 --- a/services/queue/test/expirequeues_test.js +++ b/services/queue/test/expirequeues_test.js @@ -1,6 +1,7 @@ const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(__filename, ['azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['azure'], function(mock, skipping) { helper.withQueueService(mock, skipping); // test functionality elsewhere, here we just test that it can actually run diff --git a/services/queue/test/expiretask_test.js b/services/queue/test/expiretask_test.js index 39c4fc5b80c..1616dfc888f 100644 --- a/services/queue/test/expiretask_test.js +++ b/services/queue/test/expiretask_test.js @@ -3,8 +3,9 @@ const slugid = require('slugid'); const taskcluster = require('taskcluster-client'); const assume = require('assume'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(__filename, ['taskcluster', 'aws', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster', 'aws', 'azure'], function(mock, skipping) { helper.withAmazonIPRanges(mock, skipping); helper.withPulse(mock, skipping); helper.withS3(mock, skipping); diff --git a/services/queue/test/gettask_test.js b/services/queue/test/gettask_test.js index d394a651153..055e27d7cb5 100644 --- a/services/queue/test/gettask_test.js +++ b/services/queue/test/gettask_test.js @@ -2,8 +2,9 @@ const slugid = require('slugid'); const taskcluster = require('taskcluster-client'); const assume = require('assume'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(__filename, ['taskcluster', 'aws', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster', 'aws', 'azure'], function(mock, skipping) { helper.withAmazonIPRanges(mock, skipping); helper.withPulse(mock, skipping); helper.withS3(mock, skipping); diff --git a/services/queue/test/querytasks_test.js b/services/queue/test/querytasks_test.js index 482dc278d1d..6d1944cdaa5 100644 --- a/services/queue/test/querytasks_test.js +++ b/services/queue/test/querytasks_test.js @@ -3,8 +3,9 @@ const slugid = require('slugid'); const taskcluster = require('taskcluster-client'); const assume = require('assume'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(__filename, ['taskcluster', 'aws', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster', 'aws', 'azure'], function(mock, skipping) { helper.withAmazonIPRanges(mock, skipping); helper.withPulse(mock, skipping); helper.withS3(mock, skipping); diff --git a/services/queue/test/queueservice_test.js b/services/queue/test/queueservice_test.js index 0a6ca02150a..0e16788df5e 100644 --- a/services/queue/test/queueservice_test.js +++ b/services/queue/test/queueservice_test.js @@ -10,7 +10,7 @@ const assume = require('assume'); const testing = require('taskcluster-lib-testing'); const helper = require('./helper'); -helper.secrets.mockSuite(__filename, ['azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['azure'], function(mock, skipping) { let queueService; suiteSetup(async () => { diff --git a/services/queue/test/references_test.js b/services/queue/test/references_test.js index 93de192f443..e06e221d42d 100644 --- a/services/queue/test/references_test.js +++ b/services/queue/test/references_test.js @@ -2,8 +2,9 @@ const builder = require('../src/api'); const exchanges = require('../src/exchanges'); const helper = require('./helper'); const References = require('taskcluster-lib-references'); +const testing = require('taskcluster-lib-testing'); -suite('references_test.js', function() { +suite(testing.suiteName(), function() { test('references validate', async function() { const schemaset = await helper.load('schemaset'); const references = References.fromService({schemaset, builder, exchanges}); diff --git a/services/queue/test/reruntask_test.js b/services/queue/test/reruntask_test.js index af42334d20b..4a6aa680e25 100644 --- a/services/queue/test/reruntask_test.js +++ b/services/queue/test/reruntask_test.js @@ -3,8 +3,9 @@ const assert = require('assert'); const slugid = require('slugid'); const taskcluster = require('taskcluster-client'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(__filename, ['taskcluster', 'aws', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster', 'aws', 'azure'], function(mock, skipping) { helper.withAmazonIPRanges(mock, skipping); helper.withPulse(mock, skipping); helper.withS3(mock, skipping); diff --git a/services/queue/test/resolvetask_test.js b/services/queue/test/resolvetask_test.js index d03bdae0f89..35ccf672c30 100644 --- a/services/queue/test/resolvetask_test.js +++ b/services/queue/test/resolvetask_test.js @@ -4,8 +4,9 @@ const slugid = require('slugid'); const taskcluster = require('taskcluster-client'); const assume = require('assume'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(__filename, ['taskcluster', 'aws', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster', 'aws', 'azure'], function(mock, skipping) { helper.withAmazonIPRanges(mock, skipping); helper.withPulse(mock, skipping); helper.withS3(mock, skipping); diff --git a/services/queue/test/retry_test.js b/services/queue/test/retry_test.js index bc0a716206d..797458745f9 100644 --- a/services/queue/test/retry_test.js +++ b/services/queue/test/retry_test.js @@ -5,7 +5,7 @@ const assume = require('assume'); const helper = require('./helper'); const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(__filename, ['taskcluster', 'aws', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster', 'aws', 'azure'], function(mock, skipping) { helper.withAmazonIPRanges(mock, skipping); helper.withPulse(mock, skipping); helper.withS3(mock, skipping); diff --git a/services/queue/test/taskgroup_test.js b/services/queue/test/taskgroup_test.js index 9cd113ed0fd..8494821b250 100644 --- a/services/queue/test/taskgroup_test.js +++ b/services/queue/test/taskgroup_test.js @@ -7,7 +7,7 @@ const assume = require('assume'); const helper = require('./helper'); const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(__filename, ['taskcluster', 'aws', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster', 'aws', 'azure'], function(mock, skipping) { helper.withAmazonIPRanges(mock, skipping); helper.withPollingServices(mock, skipping); helper.withPulse(mock, skipping); diff --git a/services/queue/test/validate_test.js b/services/queue/test/validate_test.js index 7e4688874cc..b8fd923d3d0 100644 --- a/services/queue/test/validate_test.js +++ b/services/queue/test/validate_test.js @@ -1,7 +1,7 @@ const testing = require('taskcluster-lib-testing'); const path = require('path'); -suite('validate_test.js', () => { +suite(testing.suiteName(), () => { // Run test cases using schemas testing utility from taskcluster-base testing.schemas({ schemasetOptions: { diff --git a/services/queue/test/workerinfo_test.js b/services/queue/test/workerinfo_test.js index 28b6d03cad2..f56cdd9ae1d 100644 --- a/services/queue/test/workerinfo_test.js +++ b/services/queue/test/workerinfo_test.js @@ -2,8 +2,9 @@ const assert = require('assert'); const slugid = require('slugid'); const taskcluster = require('taskcluster-client'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite(__filename, ['taskcluster', 'aws', 'azure'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster', 'aws', 'azure'], function(mock, skipping) { helper.withAmazonIPRanges(mock, skipping); helper.withPulse(mock, skipping); helper.withS3(mock, skipping); diff --git a/services/secrets/test/api_test.js b/services/secrets/test/api_test.js index d13756587a5..1bc8701831e 100644 --- a/services/secrets/test/api_test.js +++ b/services/secrets/test/api_test.js @@ -2,8 +2,9 @@ const helper = require('./helper'); const assert = require('assert'); const slugid = require('slugid'); const taskcluster = require('taskcluster-client'); +const testing = require('taskcluster-lib-testing'); -helper.secrets.mockSuite('api_test.js', ['taskcluster'], function(mock, skipping) { +helper.secrets.mockSuite(testing.suiteName(), ['taskcluster'], function(mock, skipping) { helper.withEntities(mock, skipping); helper.withServer(mock, skipping); diff --git a/services/secrets/test/references_test.js b/services/secrets/test/references_test.js index 8782e721dc9..54112bd4313 100644 --- a/services/secrets/test/references_test.js +++ b/services/secrets/test/references_test.js @@ -1,8 +1,9 @@ const builder = require('../src/api'); const helper = require('./helper'); const References = require('taskcluster-lib-references'); +const testing = require('taskcluster-lib-testing'); -suite('references_test.js', function() { +suite(testing.suiteName(), function() { test('references validate', async function() { const schemaset = await helper.load('schemaset'); const references = References.fromService({schemaset, builder}); diff --git a/services/treeherder/test/artifact_links_test.js b/services/treeherder/test/artifact_links_test.js index 1cb6e38e326..b9344953081 100644 --- a/services/treeherder/test/artifact_links_test.js +++ b/services/treeherder/test/artifact_links_test.js @@ -3,10 +3,11 @@ const artifactLinkTransform = require('../src/transform/artifact_links'); const helper = require('./helper'); const taskcluster = require('taskcluster-client'); const MonitorManager = require('taskcluster-lib-monitor'); +const testing = require('taskcluster-lib-testing'); let monitor, queue, fakeArtifacts; -suite('artifact link transform', () => { +suite(testing.suiteName(), () => { helper.withLoader(); suiteSetup(async () => { diff --git a/services/treeherder/test/create_job_message_test.js b/services/treeherder/test/create_job_message_test.js index b1a59d487d3..914f4ad1558 100644 --- a/services/treeherder/test/create_job_message_test.js +++ b/services/treeherder/test/create_job_message_test.js @@ -5,10 +5,11 @@ const jobMessage = require('./fixtures/job_message'); const parseRoute = require('../src/util/route_parser'); const libUrls = require('taskcluster-lib-urls'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); let task, status, expected, pushInfo; -suite('build job message', () => { +suite(testing.suiteName(), () => { helper.withLoader(); helper.withHandler(); diff --git a/services/treeherder/test/handle_message_test.js b/services/treeherder/test/handle_message_test.js index 738cc6c99fd..791f0a08292 100644 --- a/services/treeherder/test/handle_message_test.js +++ b/services/treeherder/test/handle_message_test.js @@ -1,7 +1,8 @@ const assert = require('assert'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); -suite('handle message', function() { +suite(testing.suiteName(), function() { helper.withLoader(); helper.withHandler(); diff --git a/services/treeherder/test/handle_task_completed_test.js b/services/treeherder/test/handle_task_completed_test.js index acb2d8eaa8f..d3545b07d2f 100644 --- a/services/treeherder/test/handle_task_completed_test.js +++ b/services/treeherder/test/handle_task_completed_test.js @@ -4,10 +4,11 @@ const statusMessage = require('./fixtures/task_status'); const jobMessage = require('./fixtures/job_message'); const parseRoute = require('../src/util/route_parser'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); let task, status, expected, pushInfo; -suite('handle completed job', () => { +suite(testing.suiteName(), () => { helper.withLoader(); helper.withHandler(); diff --git a/services/treeherder/test/handle_task_exception_test.js b/services/treeherder/test/handle_task_exception_test.js index d319f0f6433..f88ea29896a 100644 --- a/services/treeherder/test/handle_task_exception_test.js +++ b/services/treeherder/test/handle_task_exception_test.js @@ -4,10 +4,11 @@ const statusMessage = require('./fixtures/task_status'); const jobMessage = require('./fixtures/job_message'); const parseRoute = require('../src/util/route_parser'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); let task, status, expected, pushInfo; -suite('handle exception job', () => { +suite(testing.suiteName(), () => { helper.withLoader(); helper.withHandler(); diff --git a/services/treeherder/test/handle_task_failed_test.js b/services/treeherder/test/handle_task_failed_test.js index b6606869d43..27acab40a5c 100644 --- a/services/treeherder/test/handle_task_failed_test.js +++ b/services/treeherder/test/handle_task_failed_test.js @@ -4,10 +4,11 @@ const statusMessage = require('./fixtures/task_status'); const jobMessage = require('./fixtures/job_message'); const parseRoute = require('../src/util/route_parser'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); let task, status, expected, pushInfo; -suite('handle failed job', () => { +suite(testing.suiteName(), () => { helper.withLoader(); helper.withHandler(); diff --git a/services/treeherder/test/handle_task_rerun_test.js b/services/treeherder/test/handle_task_rerun_test.js index f6d1f26acc2..51cf408757d 100644 --- a/services/treeherder/test/handle_task_rerun_test.js +++ b/services/treeherder/test/handle_task_rerun_test.js @@ -4,10 +4,11 @@ const statusMessage = require('./fixtures/task_status'); const jobMessage = require('./fixtures/job_message'); const parseRoute = require('../src/util/route_parser'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); let task, status, expected, pushInfo; -suite('handle rerun job', () => { +suite(testing.suiteName(), () => { helper.withLoader(); helper.withHandler(); diff --git a/services/treeherder/test/handle_task_running_test.js b/services/treeherder/test/handle_task_running_test.js index 885d9259d05..aee337ed303 100644 --- a/services/treeherder/test/handle_task_running_test.js +++ b/services/treeherder/test/handle_task_running_test.js @@ -4,10 +4,11 @@ const statusMessage = require('./fixtures/task_status'); const jobMessage = require('./fixtures/job_message'); const parseRoute = require('../src/util/route_parser'); const helper = require('./helper'); +const testing = require('taskcluster-lib-testing'); let task, status, expected, pushInfo; -suite('handle running job', () => { +suite(testing.suiteName(), () => { helper.withLoader(); helper.withHandler(); diff --git a/services/treeherder/test/references_test.js b/services/treeherder/test/references_test.js index cde63ccba45..37cf8e11e5f 100644 --- a/services/treeherder/test/references_test.js +++ b/services/treeherder/test/references_test.js @@ -1,8 +1,9 @@ const exchanges = require('../src/exchanges'); const helper = require('./helper'); const References = require('taskcluster-lib-references'); +const testing = require('taskcluster-lib-testing'); -suite('references_test.js', function() { +suite(testing.suiteName(), function() { test('references validate', async function() { const schemaset = await helper.load('schemaset'); const references = References.fromService({schemaset, exchanges}); diff --git a/services/treeherder/test/route_parsing_test.js b/services/treeherder/test/route_parsing_test.js index c4bb1e6865d..53ffeae3fec 100644 --- a/services/treeherder/test/route_parsing_test.js +++ b/services/treeherder/test/route_parsing_test.js @@ -1,7 +1,8 @@ const assert = require('assert'); const parseRoute = require('../src/util/route_parser'); +const testing = require('taskcluster-lib-testing'); -suite('route parsing', () => { +suite(testing.suiteName(), () => { test('valid v2 format', async () => { assert.deepEqual( parseRoute('treeherder.v2.try.XYZ.234'), diff --git a/services/web-server/test/fetch_test.js b/services/web-server/test/fetch_test.js index 956f1419288..c3c7d32d559 100644 --- a/services/web-server/test/fetch_test.js +++ b/services/web-server/test/fetch_test.js @@ -1,8 +1,9 @@ import { createServer } from 'http'; import assert from 'assert'; import fetch from '../src/utils/fetch'; +import testing from 'taskcluster-lib-testing'; -describe('fetch', () => { +describe(testing.suiteName(), () => { let server; afterEach(() => { diff --git a/services/web-server/test/pulseengine_test.js b/services/web-server/test/pulseengine_test.js index 7cba414e2e8..faa4f03c0df 100644 --- a/services/web-server/test/pulseengine_test.js +++ b/services/web-server/test/pulseengine_test.js @@ -3,6 +3,7 @@ import MonitorManager from 'taskcluster-lib-monitor'; import {FakeClient} from 'taskcluster-lib-pulse'; import PulseEngine from '../src/PulseEngine'; import PulseIterator from '../src/PulseEngine/PulseIterator'; +const testing = require('taskcluster-lib-testing'); class FakePulseEngine { subscribe(subscriptions, handleMessage, handleError) { @@ -19,7 +20,7 @@ class FakePulseEngine { } } -describe('PulseEngine', function() { +describe(testing.suiteName(), function() { const manager = new MonitorManager({ serviceName: 'web-server', }); diff --git a/services/worker-manager/test/api_test.js b/services/worker-manager/test/api_test.js index fe215e765c6..9a7d12f2e73 100644 --- a/services/worker-manager/test/api_test.js +++ b/services/worker-manager/test/api_test.js @@ -2,8 +2,9 @@ const assume = require('assume'); const {client: _client, server: _server} = require('./helper'); const fs = require('fs'); const path = require('path'); +const testing = require('taskcluster-lib-testing'); -suite('API', () => { +suite(testing.suiteName(), () => { let server; let client; let workerConfig; diff --git a/services/worker-manager/test/bid_test.js b/services/worker-manager/test/bid_test.js index 78aa49198d8..444a7cd70d9 100644 --- a/services/worker-manager/test/bid_test.js +++ b/services/worker-manager/test/bid_test.js @@ -1,7 +1,8 @@ const assume = require('assume'); const {Bid} = require('../src/bid'); +const testing = require('taskcluster-lib-testing'); -suite('Bid', () => { +suite(testing.suiteName(), () => { test('should be able to create a Bid', () => { new Bid({ providerId: 'provider-1', diff --git a/services/worker-manager/test/convert_test.js b/services/worker-manager/test/convert_test.js index 07b594a6cec..55e479fc8ab 100644 --- a/services/worker-manager/test/convert_test.js +++ b/services/worker-manager/test/convert_test.js @@ -2,12 +2,11 @@ const path = require('path'); const fs = require('fs'); const assume = require('assume'); const {convert} = require('../bin/convert'); - const {buildWorkerConfiguration} = require('../src/worker-config'); - const memory = require('memory-streams'); +const testing = require('taskcluster-lib-testing'); -suite('AWS Provisioner WorkerType conversion', () => { +suite(testing.suiteName(), () => { test('should convert as expected', async () => { let output = new memory.WritableStream(); let input = fs.createReadStream(path.join(__dirname, 'convert-input.json')); diff --git a/services/worker-manager/test/data-storage_test.js b/services/worker-manager/test/data-storage_test.js index 0b82f6ba3a9..b29b1e091ac 100644 --- a/services/worker-manager/test/data-storage_test.js +++ b/services/worker-manager/test/data-storage_test.js @@ -1,8 +1,9 @@ const sinon = require('sinon'); const assume = require('assume'); const {BaseDatastore, InMemoryDatastore} = require('../src/data-storage'); +const testing = require('taskcluster-lib-testing'); -suite('Base Datastore', () => { +suite(testing.suiteName(), () => { const sandbox = sinon.createSandbox(); let ds; diff --git a/services/worker-manager/test/errors_test.js b/services/worker-manager/test/errors_test.js index 81f909c3ccc..2957d9ce547 100644 --- a/services/worker-manager/test/errors_test.js +++ b/services/worker-manager/test/errors_test.js @@ -1,7 +1,8 @@ const assume = require('assume'); const {errors} = require('../src/base'); +const testing = require('taskcluster-lib-testing'); -suite('errors', () => { +suite(testing.suiteName(), () => { test('should be able to create an error', () => { let error = new errors.InvalidProvider('errMsg', {prop1: 123}); assume(error).has.property('code', 'InvalidProvider'); diff --git a/services/worker-manager/test/object_test.js b/services/worker-manager/test/object_test.js index a6943295c40..12ad35256bf 100644 --- a/services/worker-manager/test/object_test.js +++ b/services/worker-manager/test/object_test.js @@ -1,7 +1,8 @@ const assume = require('assume'); const {WMObject, errors} = require('../src/base'); +const testing = require('taskcluster-lib-testing'); -suite('WMObject', () => { +suite(testing.suiteName(), () => { test('should be creatable', () => { const actual = new WMObject({id: 'wm-1'}); assume(actual).has.property('id', 'wm-1'); diff --git a/services/worker-manager/test/provisioner_test.js b/services/worker-manager/test/provisioner_test.js index 1c82b5875b7..3208e44f7dc 100644 --- a/services/worker-manager/test/provisioner_test.js +++ b/services/worker-manager/test/provisioner_test.js @@ -3,6 +3,7 @@ const fs = require('fs'); const sinon = require('sinon'); const sandbox = sinon.createSandbox(); const moment = require('moment'); +const testing = require('taskcluster-lib-testing'); const {InMemoryDatastore} = require('../src/data-storage'); const {Provisioner} = require('../src/provisioner'); @@ -53,7 +54,7 @@ class FakeBiddingStrategy extends BiddingStrategy { async selectBids() {} } -suite('Provisioner', () => { +suite(testing.suiteName(), () => { let datastore; let provider; let biddingStrategy; diff --git a/services/worker-manager/test/rules_test.js b/services/worker-manager/test/rules_test.js index d9b7a2940bb..961eb6e294b 100644 --- a/services/worker-manager/test/rules_test.js +++ b/services/worker-manager/test/rules_test.js @@ -1,394 +1,397 @@ const assume = require('assume'); +const testing = require('taskcluster-lib-testing'); const {errors} = require('../src/base'); const {Ruleset, Rule, Conditions, assign} = require('../src/rules'); -suite('assign()', () => { - test('should be able to assign an empty object', () => { - let expected = {a: 1, b: true, c: 'john'}; - let actual = {}; +suite(testing.suiteName(), function () { + suite('assign()', () => { + test('should be able to assign an empty object', () => { + let expected = {a: 1, b: true, c: 'john'}; + let actual = {}; - assign(actual, expected); - assume(actual).deeply.equals(expected); - }); - - test('should be able to overwrite non-nested properties in an object', () => { - let expected = {a: 1, b: true, c: 'john'}; - let actual = {a: 2, b: false, c: 'notjohn'}; - - assign(actual, expected); - assume(actual).deeply.equals(expected); - }); - - test('should be able to overwrite nested properties in an object', () => { - let expected = {a: 1, b: {c: {d: 2}}}; - let actual = {a: 1, b: {c: {d: 3}}}; + assign(actual, expected); + assume(actual).deeply.equals(expected); + }); - assign(actual, expected); - assume(actual).deeply.equals(expected); - }); + test('should be able to overwrite non-nested properties in an object', () => { + let expected = {a: 1, b: true, c: 'john'}; + let actual = {a: 2, b: false, c: 'notjohn'}; - test('should be able to overwrite non-object property with object', () => { - let expected = {a: 1, b: {c: {d: 2}}}; - let actual = {a: 1, b: {c: 3}}; + assign(actual, expected); + assume(actual).deeply.equals(expected); + }); - assign(actual, expected); - assume(actual).deeply.equals(expected); - }); + test('should be able to overwrite nested properties in an object', () => { + let expected = {a: 1, b: {c: {d: 2}}}; + let actual = {a: 1, b: {c: {d: 3}}}; - test('should be able to create non-existing object', () => { - let expected = {a: 1, b: {c: {d: 2}}}; - let actual = {}; + assign(actual, expected); + assume(actual).deeply.equals(expected); + }); - assign(actual, expected); - assume(actual).deeply.equals(expected); - }); + test('should be able to overwrite non-object property with object', () => { + let expected = {a: 1, b: {c: {d: 2}}}; + let actual = {a: 1, b: {c: 3}}; - test('should be able to delete properties in an object', () => { - let expected = {a: 1}; - let actual = {a: 1, b: 2}; + assign(actual, expected); + assume(actual).deeply.equals(expected); + }); - assign(actual, {b: null}); - assume(actual).deeply.equals(expected); - }); + test('should be able to create non-existing object', () => { + let expected = {a: 1, b: {c: {d: 2}}}; + let actual = {}; - test('should throw for a function property', () => { - assume(() => { - assign({}, {a: () => {}}); - }).throws(errors.InvalidValues); - }); + assign(actual, expected); + assume(actual).deeply.equals(expected); + }); -}); + test('should be able to delete properties in an object', () => { + let expected = {a: 1}; + let actual = {a: 1, b: 2}; -suite('Conditions', () => { - let nullCondition = new Conditions({id: 'cond1', conditions: null}); - suite('_compare()', () => { - test('should return true', () => { - assume(nullCondition._compare('string', 'string')).is.ok(); + assign(actual, {b: null}); + assume(actual).deeply.equals(expected); }); - test('should return false', () => { - assume(nullCondition._compare('string', 'string')).is.ok(); + + test('should throw for a function property', () => { + assume(() => { + assign({}, {a: () => {}}); + }).throws(errors.InvalidValues); }); + }); - suite('_evaluateCondition()', () => { - test('should return true when a single string satisifies requirement', () => { - let conditions = new Conditions({ - id: 'cond1', - conditions: { - string: 'test', - }, + suite('Conditions', () => { + let nullCondition = new Conditions({id: 'cond1', conditions: null}); + suite('_compare()', () => { + test('should return true', () => { + assume(nullCondition._compare('string', 'string')).is.ok(); }); - assume(conditions.evaluate({string: 'test'})).is.ok(); - }); - - test('should return true when one of many string satisifies requirement', () => { - let conditions = new Conditions({ - id: 'cond1', - conditions: { - string: ['abc', 'test', 'def'], - }, + test('should return false', () => { + assume(nullCondition._compare('string', 'string')).is.ok(); }); - assume(conditions.evaluate({string: 'test'})).is.ok(); }); - test('should return false when a single string does not satisfy requirement', () => { - let conditions = new Conditions({ - id: 'cond1', - conditions: { - string: 'nottest', - }, + suite('_evaluateCondition()', () => { + test('should return true when a single string satisifies requirement', () => { + let conditions = new Conditions({ + id: 'cond1', + conditions: { + string: 'test', + }, + }); + assume(conditions.evaluate({string: 'test'})).is.ok(); }); - assume(conditions.evaluate({string: 'test'})).is.not.ok(); - }); - test('should return false when none of many string satisifies requirement', () => { - let conditions = new Conditions({ - id: 'cond1', - conditions: { - string: ['abc', 'def'], - }, + test('should return true when one of many string satisifies requirement', () => { + let conditions = new Conditions({ + id: 'cond1', + conditions: { + string: ['abc', 'test', 'def'], + }, + }); + assume(conditions.evaluate({string: 'test'})).is.ok(); }); - assume(conditions.evaluate({string: 'test'})).is.not.ok(); - }); - }); - - suite('evaluate()', () => { - test('should return true when condition is null', () => { - let conditions = new Conditions({id: 'cond1', conditions: null}); - assume(conditions.evaluate()).is.ok(); - }); - test('should throw when satisfiers is not object', () => { - let conditions = new Conditions({ - id: 'cond1', - conditions: { - string: 'test', - }, + test('should return false when a single string does not satisfy requirement', () => { + let conditions = new Conditions({ + id: 'cond1', + conditions: { + string: 'nottest', + }, + }); + assume(conditions.evaluate({string: 'test'})).is.not.ok(); }); - assume(() => { - conditions.evaluate(() => {}); - }).throws(errors.InvalidSatisfiers); - }); - test('should evaluate false with a missing condition', () => { - let conditions = new Conditions({ - id: 'cond1', - conditions: { - string: 'test', - }, + test('should return false when none of many string satisifies requirement', () => { + let conditions = new Conditions({ + id: 'cond1', + conditions: { + string: ['abc', 'def'], + }, + }); + assume(conditions.evaluate({string: 'test'})).is.not.ok(); }); - assume(conditions.evaluate({other: 'test'})).is.not.ok(); }); - test('should return true when all requirements are met', () => { - let conditions = new Conditions({ - id: 'cond1', - conditions: { - string: 'test', - }, + suite('evaluate()', () => { + test('should return true when condition is null', () => { + let conditions = new Conditions({id: 'cond1', conditions: null}); + assume(conditions.evaluate()).is.ok(); }); - assume(conditions.evaluate({string: 'test'})).is.ok(); - }); - test('should return false when not all requirements are met', () => { - let conditions = new Conditions({ - id: 'cond1', - conditions: { - string: 'test', - }, + test('should throw when satisfiers is not object', () => { + let conditions = new Conditions({ + id: 'cond1', + conditions: { + string: 'test', + }, + }); + assume(() => { + conditions.evaluate(() => {}); + }).throws(errors.InvalidSatisfiers); }); - assume(conditions.evaluate({string: 'not-test'})).is.not.ok(); - }); - }); - suite('invalid input', () => { - test('should not allow a non-string condition', () => { - assume(() => { - new Conditions({ + test('should evaluate false with a missing condition', () => { + let conditions = new Conditions({ id: 'cond1', conditions: { - property: () => {}, + string: 'test', }, }); - }).throws(errors.InvalidConditions); - }); + assume(conditions.evaluate({other: 'test'})).is.not.ok(); + }); - test('should not allow a non-string condition in a list', () => { - assume(() => { - new Conditions({ + test('should return true when all requirements are met', () => { + let conditions = new Conditions({ id: 'cond1', conditions: { - property: () => {}, + string: 'test', }, }); - }).throws(errors.InvalidConditions); - }); - }); -}); - -suite('Rule', () => { - suite('evaluate()', () => { - let rule; - let target; + assume(conditions.evaluate({string: 'test'})).is.ok(); + }); - setup(() => { - target = { - rule1val: 'not-set', - }; - rule = new Rule({ - id: 'rule-1', - conditions: { - string: 'test', - }, - values: { - rule1val: 'set', - }, - description: 'test rule', + test('should return false when not all requirements are met', () => { + let conditions = new Conditions({ + id: 'cond1', + conditions: { + string: 'test', + }, + }); + assume(conditions.evaluate({string: 'not-test'})).is.not.ok(); }); }); - test('should return true and set values with satisfied requirements', () => { - let outcome = rule.evaluate({string: 'test'}, target); - assume(outcome).is.ok(); - assume(target).deeply.equals({rule1val: 'set'}); - }); + suite('invalid input', () => { + test('should not allow a non-string condition', () => { + assume(() => { + new Conditions({ + id: 'cond1', + conditions: { + property: () => {}, + }, + }); + }).throws(errors.InvalidConditions); + }); - test('should return false and not set values with unsatisfied requirements', () => { - let outcome = rule.evaluate({string: 'nottest'}, target); - assume(outcome).is.not.ok(); - assume(target).deeply.equals({rule1val: 'not-set'}); + test('should not allow a non-string condition in a list', () => { + assume(() => { + new Conditions({ + id: 'cond1', + conditions: { + property: () => {}, + }, + }); + }).throws(errors.InvalidConditions); + }); }); }); - suite('invalid input', () => { - test('should throw with invalid id', () => { - assume(() => { - new Rule({id: 123, conditions: {}, values: {}, description: ''}); - }).throws(errors.InvalidIdentifier); - }); + suite('Rule', () => { + suite('evaluate()', () => { + let rule; + let target; + + setup(() => { + target = { + rule1val: 'not-set', + }; + rule = new Rule({ + id: 'rule-1', + conditions: { + string: 'test', + }, + values: { + rule1val: 'set', + }, + description: 'test rule', + }); + }); - test('should throw with invalid conditions', () => { - assume(() => { - new Rule({id: 'id', conditions: 123, values: {}, description: ''}); - }).throws(errors.InvalidConditions); - }); + test('should return true and set values with satisfied requirements', () => { + let outcome = rule.evaluate({string: 'test'}, target); + assume(outcome).is.ok(); + assume(target).deeply.equals({rule1val: 'set'}); + }); - test('should throw with invalid values', () => { - assume(() => { - new Rule({id: 'id', conditions: {}, values: 123, description: ''}); - }).throws(errors.InvalidValues); + test('should return false and not set values with unsatisfied requirements', () => { + let outcome = rule.evaluate({string: 'nottest'}, target); + assume(outcome).is.not.ok(); + assume(target).deeply.equals({rule1val: 'not-set'}); + }); }); - test('should throw with invalid description', () => { - assume(() => { - new Rule({id: 'id', conditions: {}, values: {}, description: 123}); - }).throws(errors.InvalidRules); - }); - }); -}); + suite('invalid input', () => { + test('should throw with invalid id', () => { + assume(() => { + new Rule({id: 123, conditions: {}, values: {}, description: ''}); + }).throws(errors.InvalidIdentifier); + }); -suite('Ruleset', () => { + test('should throw with invalid conditions', () => { + assume(() => { + new Rule({id: 'id', conditions: 123, values: {}, description: ''}); + }).throws(errors.InvalidConditions); + }); - let rules; + test('should throw with invalid values', () => { + assume(() => { + new Rule({id: 'id', conditions: {}, values: 123, description: ''}); + }).throws(errors.InvalidValues); + }); - setup(() => { - rules = new Ruleset({ - id: 'rs-1', - rules: [{ - id: 'rule1', - conditions: { - workerType: 'worker1-extended-extended', - provider: ['ec2', 'gcp'], - }, - values: { - rule1: 'matched', - }, - description: 'worker1 in ec2 or gcp', - }, { - id: 'rule2', - conditions: { - workerType: 'worker1-extended-extended', - provider: 'ec2', - }, - values: { - rule2: 'matched', - }, - description: 'worker1 in ec2 only', - }, { - id: 'rule3', - conditions: { - workerType: 'worker2', - provider: ['ec2', 'gcp'], - }, - values: { - rule3: 'matched', - }, - description: 'worker2 in ec2 or gcp', - }, { - id: 'rule4', - conditions: { - workerType: 'worker2', - provider: 'gcp', - }, - values: { - rule4: 'matched', - }, - description: 'worker2 in gcp only', - }], + test('should throw with invalid description', () => { + assume(() => { + new Rule({id: 'id', conditions: {}, values: {}, description: 123}); + }).throws(errors.InvalidRules); + }); }); }); - test('should match worker1/ec2 correctly', () => { - assume(rules.evaluate({workerType: 'worker1-extended-extended', provider: 'ec2'})).deeply.equals({ - rule1: 'matched', - rule2: 'matched', - }); - }); + suite('Ruleset', () => { - test('should match worker1/gcp correctly', () => { - assume(rules.evaluate({workerType: 'worker1-extended-extended', provider: 'ec2'})).deeply.equals({ - rule1: 'matched', - rule2: 'matched', - }); - }); + let rules; - test('should match worker2/ec2 correctly', () => { - assume(rules.evaluate({workerType: 'worker2', provider: 'ec2'})).deeply.equals({ - rule3: 'matched', + setup(() => { + rules = new Ruleset({ + id: 'rs-1', + rules: [{ + id: 'rule1', + conditions: { + workerType: 'worker1-extended-extended', + provider: ['ec2', 'gcp'], + }, + values: { + rule1: 'matched', + }, + description: 'worker1 in ec2 or gcp', + }, { + id: 'rule2', + conditions: { + workerType: 'worker1-extended-extended', + provider: 'ec2', + }, + values: { + rule2: 'matched', + }, + description: 'worker1 in ec2 only', + }, { + id: 'rule3', + conditions: { + workerType: 'worker2', + provider: ['ec2', 'gcp'], + }, + values: { + rule3: 'matched', + }, + description: 'worker2 in ec2 or gcp', + }, { + id: 'rule4', + conditions: { + workerType: 'worker2', + provider: 'gcp', + }, + values: { + rule4: 'matched', + }, + description: 'worker2 in gcp only', + }], + }); }); - }); - test('should match worker2/gcp correctly', () => { - assume(rules.evaluate({workerType: 'worker2', provider: 'gcp'})).deeply.equals({ - rule3: 'matched', - rule4: 'matched', + + test('should match worker1/ec2 correctly', () => { + assume(rules.evaluate({workerType: 'worker1-extended-extended', provider: 'ec2'})).deeply.equals({ + rule1: 'matched', + rule2: 'matched', + }); }); - }); -}); -suite('Required Satisfiers', () => { - test('should be able to list required satisfiers on Conditions', () => { - let cond = new Conditions({ - id: 'cond1', - conditions: { - string1: 'abc', - string2: 'def', - }, + test('should match worker1/gcp correctly', () => { + assume(rules.evaluate({workerType: 'worker1-extended-extended', provider: 'ec2'})).deeply.equals({ + rule1: 'matched', + rule2: 'matched', + }); }); - assume(cond.requiredSatisfiers()).is.array(['string1', 'string2']); - }); - test('should be able to list required satisfiers on Rules', () => { - let rule = new Rule({ - id: 'rule-1', - conditions: {string1: 'abc', string2: 'def'}, - values: {}, - description: '', + test('should match worker2/ec2 correctly', () => { + assume(rules.evaluate({workerType: 'worker2', provider: 'ec2'})).deeply.equals({ + rule3: 'matched', + }); + }); + test('should match worker2/gcp correctly', () => { + assume(rules.evaluate({workerType: 'worker2', provider: 'gcp'})).deeply.equals({ + rule3: 'matched', + rule4: 'matched', + }); }); - assume(rule.requiredSatisfiers()).is.array(['string1', 'string2']); }); - test('should be able to list required satisfiers on Conditions', () => { - let rules = new Ruleset({ - id: 'ruleset-1', - rules: [{ - id: 'rule1', - conditions: { - string1: 'worker1', - string2: ['ec2', 'gcp'], - }, - values: {}, - description: '', - }, { - id: 'rule2', - conditions: { - string2: 'worker1', - }, - values: {}, - description: '', - }, { - id: 'rule3', - conditions: { - string3: 'worker2', - string4: ['ec2', 'gcp'], - }, - values: {}, - description: '', - }, { - id: 'rule4', + suite('Required Satisfiers', () => { + test('should be able to list required satisfiers on Conditions', () => { + let cond = new Conditions({ + id: 'cond1', conditions: { - string5: 'worker2', + string1: 'abc', + string2: 'def', }, + }); + assume(cond.requiredSatisfiers()).is.array(['string1', 'string2']); + }); + + test('should be able to list required satisfiers on Rules', () => { + let rule = new Rule({ + id: 'rule-1', + conditions: {string1: 'abc', string2: 'def'}, values: {}, description: '', - }], + }); + assume(rule.requiredSatisfiers()).is.array(['string1', 'string2']); + }); + + test('should be able to list required satisfiers on Conditions', () => { + let rules = new Ruleset({ + id: 'ruleset-1', + rules: [{ + id: 'rule1', + conditions: { + string1: 'worker1', + string2: ['ec2', 'gcp'], + }, + values: {}, + description: '', + }, { + id: 'rule2', + conditions: { + string2: 'worker1', + }, + values: {}, + description: '', + }, { + id: 'rule3', + conditions: { + string3: 'worker2', + string4: ['ec2', 'gcp'], + }, + values: {}, + description: '', + }, { + id: 'rule4', + conditions: { + string5: 'worker2', + }, + values: {}, + description: '', + }], + }); + assume(rules.requiredSatisfiers()).is.array([ + 'string1', + 'string2', + 'string3', + 'string4', + 'string5', + ]); }); - assume(rules.requiredSatisfiers()).is.array([ - 'string1', - 'string2', - 'string3', - 'string4', - 'string5', - ]); }); }); diff --git a/services/worker-manager/test/worker-config_test.js b/services/worker-manager/test/worker-config_test.js index b42e0dd139b..9dfab4412ed 100644 --- a/services/worker-manager/test/worker-config_test.js +++ b/services/worker-manager/test/worker-config_test.js @@ -1,4 +1,5 @@ const assume = require('assume'); +const testing = require('taskcluster-lib-testing'); const {errors} = require('../src/base'); @@ -70,232 +71,59 @@ function mockRules() { }]; } -suite('WorkerConfiguration', () => { +suite(testing.suiteName(), function() { + suite('WorkerConfiguration', () => { - let workerConfiguration; + let workerConfiguration; - setup(() => { - workerConfiguration = new WorkerConfiguration({ - id: 'worker-config-1', - rules: new Ruleset({id: 'worker-config-1', rules: mockRules()}), - workerTypeConfigurations: [ - new Map([ - ['workerType', 'worker-type-1'], - ['biddingStrategyId', 'bidding-strategy-1'], - ['providerIds', ['provider-1']], - ]), - new Map([ - ['workerType', 'worker-type-2'], - ['biddingStrategyId', 'bidding-strategy-2'], - ['providerIds', ['provider-2']], - ]), - ], - }); - }); - - test('should be able to evaluate a worker configuration for a bidding strategy', () => { - let outcome = workerConfiguration.evaluate({ - workerType: 'worker-type-1', - biddingStrategyId: 'bidding-strategy-1', - }); - - assume(outcome).deeply.equals({ - biddingStrategyData: { - info1: 'bidding-rule-applied', - }, - documentationData: { - info1: 'docs-rule-applied', - }, - providerData: { - info3: 'rule-3-applied', - }, - workerType: 'worker-type-1', - schemaData: { - }, - }); - }); - - test('should be able to evaluate a worker configuration for a provider', () => { - let outcome = workerConfiguration.evaluate({ - workerType: 'worker-type-1', - providerId: 'provider-1', - }); - - assume(outcome).deeply.equals({ - biddingStrategyData: { - }, - documentationData: { - info1: 'docs-rule-applied', - }, - providerData: { - info1: 'rule-1-applied', - info3: 'rule-3-applied', - }, - workerType: 'worker-type-1', - schemaData: { - }, - }); - }); - - test('should throw when when unexpected provider data results', () => { - assume(() => { - workerConfiguration.evaluate({ - biddingStrategyId: 'bidding-strategy-1', - }); - }).throws(errors.InvalidSatisfiers); - }); - - test('should throw when when unexpected bidding strategy data results', () => { - assume(() => { - workerConfiguration.evaluate({ - providerId: 'provider-1', - }); - }).throws(errors.InvalidSatisfiers); - }); - - test('should throw when all satisfiers are missing', () => { - assume(() => { - workerConfiguration.evaluate(); - }).throws(errors.InvalidSatisfiers); - }); - - test('should throw when worker type satisfier is missing', () => { - assume(() => { - workerConfiguration.evaluate({ - providerId: 'provider-1', - }); - }).throws(errors.InvalidSatisfiers); - }); - - test('should throw when missing fields for dynamic worker type', () => { - assume(() => { - new WorkerConfiguration({ - id: 'failbad', + setup(() => { + workerConfiguration = new WorkerConfiguration({ + id: 'worker-config-1', + rules: new Ruleset({id: 'worker-config-1', rules: mockRules()}), workerTypeConfigurations: [ - new Map([['workerType', 'worker-type-1'], ['providerIds', 'provider-1']]), + new Map([ + ['workerType', 'worker-type-1'], + ['biddingStrategyId', 'bidding-strategy-1'], + ['providerIds', ['provider-1']], + ]), + new Map([ + ['workerType', 'worker-type-2'], + ['biddingStrategyId', 'bidding-strategy-2'], + ['providerIds', ['provider-2']], + ]), ], - rules: mockRules(), }); - }).throws(errors.InvalidWorkerConfiguration); - }); - - test('should be able to list worker types', () => { - for (let workerType of workerConfiguration.workerTypes()) { - assume(workerType).is.a.string; - } - }); -}); - -suite('buildWorkerConfiguration', () => { - test('should throw error when missing config and rules/workerTypeConfigurations', () => { - assume(() => { - buildWorkerConfiguration({}); - }).throws(errors.InvalidWorkerConfiguration); - }); + }); - suite('provisioned worker configurations', () => { - test('should allow setting no defaults', () => { - let result = buildWorkerConfiguration({ - id: 'worker-configuration-1', - workerTypes: [{ - workerType: 'worker-type-1', - providerIds: ['provider-1'], - biddingStrategyId: 'bidding-strategy-1', - }], - rules: mockRules(), - }); - assume(result.evaluate({ - workerType: 'worker-type-1', - providerId: 'provider-1', - })).deeply.equals({ - biddingStrategyData: { - }, - documentationData: { - info1: 'docs-rule-applied', - }, - providerData: { - info1: 'rule-1-applied', - info3: 'rule-3-applied', - }, + test('should be able to evaluate a worker configuration for a bidding strategy', () => { + let outcome = workerConfiguration.evaluate({ workerType: 'worker-type-1', - schemaData: { - }, + biddingStrategyId: 'bidding-strategy-1', }); - assume(result).instanceof(WorkerConfiguration); - }); - test('should allow setting default provisioner ids', () => { - let result = buildWorkerConfiguration({ - id: 'worker-configuration-1', - providerIds: ['provider-1'], - workerTypes: [{ - workerType: 'worker-type-1', - biddingStrategyId: 'bidding-strategy-1', - }], - rules: mockRules(), - }); - assume(result.evaluate({ - workerType: 'worker-type-1', - providerId: 'provider-1', - })).deeply.equals({ + assume(outcome).deeply.equals({ biddingStrategyData: { + info1: 'bidding-rule-applied', }, documentationData: { info1: 'docs-rule-applied', }, providerData: { - info1: 'rule-1-applied', info3: 'rule-3-applied', }, workerType: 'worker-type-1', schemaData: { }, }); - assume(result).instanceof(WorkerConfiguration); }); - test('should allow setting default bidding strategy id', () => { - let result = buildWorkerConfiguration({ - id: 'worker-configuration-1', - biddingStrategyId: 'bidding-strategy-1', - workerTypes: [{ - workerType: 'worker-type-1', - providerIds: ['provider-1'], - }], - rules: mockRules(), - }); - assume(result.evaluate({ + test('should be able to evaluate a worker configuration for a provider', () => { + let outcome = workerConfiguration.evaluate({ workerType: 'worker-type-1', providerId: 'provider-1', - })).deeply.equals({ - biddingStrategyData: { - }, - documentationData: { - info1: 'docs-rule-applied', - }, - providerData: { - info1: 'rule-1-applied', - info3: 'rule-3-applied', - }, - workerType: 'worker-type-1', - schemaData: { - }, }); - assume(result).instanceof(WorkerConfiguration); - }); - test('should string worker type list', () => { - let result = buildWorkerConfiguration({ - id: 'worker-configuration-1', - providerIds: ['provider-1'], - biddingStrategyId: 'bidding-strategy-1', - workerTypes: ['worker-type-1'], - rules: mockRules(), - }); - assume(result.evaluate({ - workerType: 'worker-type-1', - providerId: 'provider-1', - })).deeply.equals({ + assume(outcome).deeply.equals({ biddingStrategyData: { }, documentationData: { @@ -309,33 +137,208 @@ suite('buildWorkerConfiguration', () => { schemaData: { }, }); - assume(result).instanceof(WorkerConfiguration); }); - test('should throw without setting provisioner ids', () => { + test('should throw when when unexpected provider data results', () => { + assume(() => { + workerConfiguration.evaluate({ + biddingStrategyId: 'bidding-strategy-1', + }); + }).throws(errors.InvalidSatisfiers); + }); + + test('should throw when when unexpected bidding strategy data results', () => { + assume(() => { + workerConfiguration.evaluate({ + providerId: 'provider-1', + }); + }).throws(errors.InvalidSatisfiers); + }); + + test('should throw when all satisfiers are missing', () => { + assume(() => { + workerConfiguration.evaluate(); + }).throws(errors.InvalidSatisfiers); + }); + + test('should throw when worker type satisfier is missing', () => { + assume(() => { + workerConfiguration.evaluate({ + providerId: 'provider-1', + }); + }).throws(errors.InvalidSatisfiers); + }); + + test('should throw when missing fields for dynamic worker type', () => { assume(() => { - buildWorkerConfiguration({ + new WorkerConfiguration({ + id: 'failbad', + workerTypeConfigurations: [ + new Map([['workerType', 'worker-type-1'], ['providerIds', 'provider-1']]), + ], + rules: mockRules(), + }); + }).throws(errors.InvalidWorkerConfiguration); + }); + + test('should be able to list worker types', () => { + for (let workerType of workerConfiguration.workerTypes()) { + assume(workerType).is.a.string; + } + }); + }); + + suite('buildWorkerConfiguration', () => { + test('should throw error when missing config and rules/workerTypeConfigurations', () => { + assume(() => { + buildWorkerConfiguration({}); + }).throws(errors.InvalidWorkerConfiguration); + }); + + suite('provisioned worker configurations', () => { + test('should allow setting no defaults', () => { + let result = buildWorkerConfiguration({ id: 'worker-configuration-1', workerTypes: [{ workerType: 'worker-type-1', + providerIds: ['provider-1'], biddingStrategyId: 'bidding-strategy-1', }], rules: mockRules(), }); - }).throws(errors.InvalidWorkerConfiguration); - }); + assume(result.evaluate({ + workerType: 'worker-type-1', + providerId: 'provider-1', + })).deeply.equals({ + biddingStrategyData: { + }, + documentationData: { + info1: 'docs-rule-applied', + }, + providerData: { + info1: 'rule-1-applied', + info3: 'rule-3-applied', + }, + workerType: 'worker-type-1', + schemaData: { + }, + }); + assume(result).instanceof(WorkerConfiguration); + }); - test('should throw without setting bidding strategy id', () => { - assume(() => { - buildWorkerConfiguration({ + test('should allow setting default provisioner ids', () => { + let result = buildWorkerConfiguration({ id: 'worker-configuration-1', + providerIds: ['provider-1'], + workerTypes: [{ + workerType: 'worker-type-1', + biddingStrategyId: 'bidding-strategy-1', + }], + rules: mockRules(), + }); + assume(result.evaluate({ + workerType: 'worker-type-1', + providerId: 'provider-1', + })).deeply.equals({ + biddingStrategyData: { + }, + documentationData: { + info1: 'docs-rule-applied', + }, + providerData: { + info1: 'rule-1-applied', + info3: 'rule-3-applied', + }, + workerType: 'worker-type-1', + schemaData: { + }, + }); + assume(result).instanceof(WorkerConfiguration); + }); + + test('should allow setting default bidding strategy id', () => { + let result = buildWorkerConfiguration({ + id: 'worker-configuration-1', + biddingStrategyId: 'bidding-strategy-1', workerTypes: [{ workerType: 'worker-type-1', providerIds: ['provider-1'], }], rules: mockRules(), }); - }).throws(errors.InvalidWorkerConfiguration); + assume(result.evaluate({ + workerType: 'worker-type-1', + providerId: 'provider-1', + })).deeply.equals({ + biddingStrategyData: { + }, + documentationData: { + info1: 'docs-rule-applied', + }, + providerData: { + info1: 'rule-1-applied', + info3: 'rule-3-applied', + }, + workerType: 'worker-type-1', + schemaData: { + }, + }); + assume(result).instanceof(WorkerConfiguration); + }); + + test('should string worker type list', () => { + let result = buildWorkerConfiguration({ + id: 'worker-configuration-1', + providerIds: ['provider-1'], + biddingStrategyId: 'bidding-strategy-1', + workerTypes: ['worker-type-1'], + rules: mockRules(), + }); + assume(result.evaluate({ + workerType: 'worker-type-1', + providerId: 'provider-1', + })).deeply.equals({ + biddingStrategyData: { + }, + documentationData: { + info1: 'docs-rule-applied', + }, + providerData: { + info1: 'rule-1-applied', + info3: 'rule-3-applied', + }, + workerType: 'worker-type-1', + schemaData: { + }, + }); + assume(result).instanceof(WorkerConfiguration); + }); + + test('should throw without setting provisioner ids', () => { + assume(() => { + buildWorkerConfiguration({ + id: 'worker-configuration-1', + workerTypes: [{ + workerType: 'worker-type-1', + biddingStrategyId: 'bidding-strategy-1', + }], + rules: mockRules(), + }); + }).throws(errors.InvalidWorkerConfiguration); + }); + + test('should throw without setting bidding strategy id', () => { + assume(() => { + buildWorkerConfiguration({ + id: 'worker-configuration-1', + workerTypes: [{ + workerType: 'worker-type-1', + providerIds: ['provider-1'], + }], + rules: mockRules(), + }); + }).throws(errors.InvalidWorkerConfiguration); + }); }); }); }); diff --git a/yarn.lock b/yarn.lock index 7733c01c7da..aadeaeb86f4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3438,6 +3438,13 @@ error-ex@^1.2.0: dependencies: is-arrayish "^0.2.1" +error-stack-parser@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/error-stack-parser/-/error-stack-parser-2.0.2.tgz#4ae8dbaa2bf90a8b450707b9149dcabca135520d" + integrity sha512-E1fPutRDdIj/hohG0UpT5mayXNCxXP9d+snxFsPU9X0XgccOumKraa3juDMwTUyi7+Bu5+mCGagjg4IYeNbOdw== + dependencies: + stackframe "^1.0.4" + es-abstract@^1.10.0, es-abstract@^1.5.1: version "1.13.0" resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.13.0.tgz#ac86145fdd5099d8dd49558ccba2eaf9b88e24e9" @@ -8394,6 +8401,11 @@ stack-trace@0.0.x: resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0" integrity sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA= +stackframe@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-1.0.4.tgz#357b24a992f9427cba6b545d96a14ed2cbca187b" + integrity sha512-to7oADIniaYwS3MhtCa/sQhrxidCCQiF/qp4/m5iN3ipf0Y7Xlri0f6eG29r08aL7JYl8n32AF3Q5GYBZ7K8vw== + start-server-webpack-plugin@^2.2.5: version "2.2.5" resolved "https://registry.yarnpkg.com/start-server-webpack-plugin/-/start-server-webpack-plugin-2.2.5.tgz#4a2838759b0f36acd11b0b2f5f196f289ae29d31" @@ -8727,117 +8739,56 @@ tar@^4: yallist "^3.0.2" "taskcluster-client@link:clients/client": - version "13.0.0" - dependencies: - debug "^4.0.0" - hawk "^7.0.10" - lodash "^4.17.4" - promise "^8.0.1" - slugid "^2.0.0" - superagent "^4.0.0" - taskcluster-lib-urls "^12.0.0" + version "0.0.0" + uid "" "taskcluster-lib-api@link:libraries/api": - version "12.8.1" - dependencies: - aws-sdk "^2.151.0" - body-parser "1.18.3" - debug "^4.0.0" - express "4.16.4" - hawk "^7.0.10" - lodash "^4.15.0" - promise "^8.0.1" - slugid "^2.0.0" - type-is "^1.6.15" - uuid "^3.1.0" + version "0.0.0" + uid "" "taskcluster-lib-app@link:libraries/app": - version "10.2.0" - dependencies: - content-security-policy "^0.3.0" - debug "^4.0.0" - express "4.16.4" - express-sslify "1.2.0" - hsts "^2.1.0" - lodash "4.17.11" - morgan "^1.0.0" - morgan-debug "^2.0.0" - promise "^8.0.1" - uuid "^3.3.2" + version "0.0.0" + uid "" "taskcluster-lib-azure@link:libraries/azure": - version "10.0.0" + version "0.0.0" + uid "" "taskcluster-lib-config@link:libraries/config": - version "3.0.0" - dependencies: - debug "^4.1.0" - js-yaml "^3.12.1" - lodash "^4.17.11" + version "0.0.0" + uid "" "taskcluster-lib-docs@link:libraries/docs": - version "11.0.0" - dependencies: - app-root-dir "^1.0.2" - aws-sdk "^2.147.0" - debug "^4.0.0" - lodash "^4.13.1" - mkdirp "^0.5.1" - mz "^2.7.0" - promisepipe "^3.0.0" - recursive-readdir-sync "^1.0.6" - s3-upload-stream "^1.0.7" - tar-stream "^2.0.0" + version "0.0.0" + uid "" "taskcluster-lib-iterate@link:libraries/iterate": - version "11.0.0" - dependencies: - debug "^4.1.0" + version "0.0.0" + uid "" "taskcluster-lib-loader@link:libraries/loader": - version "11.0.0" - dependencies: - assume "^2.1.0" - debug "^4.1.0" - topo-sort "^1.0.0" + version "0.0.0" + uid "" "taskcluster-lib-monitor@link:libraries/monitor": - version "11.1.1" - dependencies: - app-root-dir "^1.0.2" - chalk "^2.4.2" - fast-json-stable-stringify "^2.0.0" - serialize-error "^4.0.0" + version "0.0.0" + uid "" "taskcluster-lib-pulse@link:libraries/pulse": - version "11.1.1" - dependencies: - amqplib "^0.5.2" - aws-sdk "^2.331.0" - debug "^4.0.0" + version "0.0.0" + uid "" "taskcluster-lib-references@link:libraries/references": - version "1.5.0" - dependencies: - ajv "^6.5.5" - js-yaml "^3.12.1" - lodash "^4.17.10" - mkdirp "^0.5.1" - regex-escape "^3.4.8" - rimraf "^2.6.2" + version "0.0.0" + uid "" "taskcluster-lib-scopes@link:libraries/scopes": - version "10.0.1" + version "0.0.0" + uid "" "taskcluster-lib-testing@link:libraries/testing": - version "12.1.2" - dependencies: - debug "^4.0.0" - hawk "^7.0.10" - lodash "^4.17.10" - nock "^10.0.0" - promise "^8.0.1" - superagent "^4.0.0" + version "0.0.0" + uid "" taskcluster-lib-urls@^12.0.0: version "12.0.0" @@ -8845,18 +8796,8 @@ taskcluster-lib-urls@^12.0.0: integrity sha512-OrEFE0m3p/+mGsmIwjttLhSKg3io6MpJLhYtPNjVSZA9Ix8Y5tprN3vM6a3MjWt5asPF6AKZsfT43cgpGwJB0g== "taskcluster-lib-validate@link:libraries/validate": - version "12.0.0" - dependencies: - ajv "^6.5.0" - app-root-dir "^1.0.2" - aws-sdk "^2.142.0" - debug "^4.0.0" - js-yaml "^3.12.1" - lodash "^4.5.1" - mkdirp "^0.5.1" - promise "^8.0.1" - rimraf "^2.6.2" - walk "^2.3.9" + version "0.0.0" + uid "" taskgroup@^4.0.5, taskgroup@^4.2.0: version "4.3.1"