From fe870f073a672316eb488964c7525884a7a0eb2d Mon Sep 17 00:00:00 2001 From: Ruben Verborgh Date: Sun, 1 Nov 2020 13:52:49 +0100 Subject: [PATCH] chore: Enable/disable Docker testing with a flag. --- .eslintrc.js | 2 ++ .travis.yml | 1 + test/.eslintrc.js | 1 + test/integration/SparqlStorage.test.ts | 4 ++-- test/util/TestHelpers.ts | 7 +++++++ 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 48581dfb1..bc154780b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -40,6 +40,8 @@ module.exports = { 'dot-location': ['error', 'property'], 'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }], 'max-len': ['error', { code: 120, ignoreUrls: true }], + 'mocha/no-exports': 'off', // we are not using Mocha + 'mocha/no-skipped-tests': 'off', // we are not using Mocha 'new-cap': 'off', // used for RDF constants 'no-param-reassign': 'off', // necessary in constructor overloading 'no-underscore-dangle': 'off', // conflicts with external libraries diff --git a/.travis.yml b/.travis.yml index 015531f06..9bd91241b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ services: before_install: - npm run docker + - export TEST_DOCKER=1 script: - npm run lint diff --git a/test/.eslintrc.js b/test/.eslintrc.js index 4208aee59..9886c3797 100644 --- a/test/.eslintrc.js +++ b/test/.eslintrc.js @@ -9,6 +9,7 @@ module.exports = { rules: { '@typescript-eslint/no-unsafe-assignment': 'off', 'unicorn/no-useless-undefined': 'off', + 'no-process-env': 'off', // Need these 2 to run tests for throwing non-Error objects '@typescript-eslint/no-throw-literal': 'off', diff --git a/test/integration/SparqlStorage.test.ts b/test/integration/SparqlStorage.test.ts index f06e92b50..0be33bbca 100644 --- a/test/integration/SparqlStorage.test.ts +++ b/test/integration/SparqlStorage.test.ts @@ -4,9 +4,9 @@ import { INTERNAL_QUADS } from '../../src/util/ContentTypes'; import { MetadataController } from '../../src/util/MetadataController'; import { DataAccessorBasedConfig } from '../configs/DataAccessorBasedConfig'; import { BASE } from '../configs/Util'; -import { FileTestHelper } from '../util/TestHelpers'; +import { describeIf, FileTestHelper } from '../util/TestHelpers'; -describe('A server with a SPARQL endpoint as storage', (): void => { +describeIf('docker', 'a server with a SPARQL endpoint as storage', (): void => { describe('without acl', (): void => { const config = new DataAccessorBasedConfig(BASE, new SparqlDataAccessor('http://localhost:4000/sparql', diff --git a/test/util/TestHelpers.ts b/test/util/TestHelpers.ts index 519015ebc..0d15f2baa 100644 --- a/test/util/TestHelpers.ts +++ b/test/util/TestHelpers.ts @@ -214,3 +214,10 @@ export class FileTestHelper { return response; } } + +export const describeIf = (envFlag: string, name: string, fn: () => void): void => { + const flag = `TEST_${envFlag.toUpperCase()}`; + const enabled = !/^(|0|false)$/iu.test(process.env[flag] ?? ''); + // eslint-disable-next-line jest/valid-describe, jest/valid-title, jest/no-disabled-tests + return enabled ? describe(name, fn) : describe.skip(name, fn); +};