chore: Enable/disable Docker testing with a flag.

This commit is contained in:
Ruben Verborgh 2020-11-01 13:52:49 +01:00 committed by Joachim Van Herwegen
parent 5f4f4b08b0
commit fe870f073a
5 changed files with 13 additions and 2 deletions

View File

@ -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

View File

@ -11,6 +11,7 @@ services:
before_install:
- npm run docker
- export TEST_DOCKER=1
script:
- npm run lint

View File

@ -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',

View File

@ -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',

View File

@ -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);
};