From fc1826909f901f9937a9674ba57b049c52a4dbf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Mon, 22 Jul 2019 12:04:14 +0200 Subject: [PATCH 1/2] feat(repository-tests): rename CrudConnectorFeatures to CrudFeatures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the future, we are likely to add options that are specific to different Repository implementations, in addition to connector-specific options. Let's rename the interface to describe this enlarged scope. Signed-off-by: Miroslav Bajtoš --- .../src/__tests__/mongodb.datasource.ts | 7 ++----- .../repository-mysql/src/__tests__/mysql.datasource.ts | 7 ++----- packages/repository-tests/src/crud-test-suite.ts | 8 ++++---- .../repository-tests/src/crud/create-retrieve.suite.ts | 4 ++-- .../src/crud/freeform-properties.suite.ts | 4 ++-- .../repository-tests/src/types.repository-tests.ts | 10 +++++----- 6 files changed, 17 insertions(+), 23 deletions(-) diff --git a/acceptance/repository-mongodb/src/__tests__/mongodb.datasource.ts b/acceptance/repository-mongodb/src/__tests__/mongodb.datasource.ts index 38b4fbeccb67..1f872af2a0d5 100644 --- a/acceptance/repository-mongodb/src/__tests__/mongodb.datasource.ts +++ b/acceptance/repository-mongodb/src/__tests__/mongodb.datasource.ts @@ -3,10 +3,7 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import { - CrudConnectorFeatures, - DataSourceOptions, -} from '@loopback/repository-tests'; +import {CrudFeatures, DataSourceOptions} from '@loopback/repository-tests'; const connector = require('loopback-connector-mongodb'); @@ -17,6 +14,6 @@ export const MONGODB_CONFIG: DataSourceOptions = { database: process.env.MONGODB_DATABASE || 'repository-tests', }; -export const MONGODB_FEATURES: Partial = { +export const MONGODB_FEATURES: Partial = { idType: 'string', }; diff --git a/acceptance/repository-mysql/src/__tests__/mysql.datasource.ts b/acceptance/repository-mysql/src/__tests__/mysql.datasource.ts index c9ad6ce73842..c5ce891c0f84 100644 --- a/acceptance/repository-mysql/src/__tests__/mysql.datasource.ts +++ b/acceptance/repository-mysql/src/__tests__/mysql.datasource.ts @@ -3,10 +3,7 @@ // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT -import { - CrudConnectorFeatures, - DataSourceOptions, -} from '@loopback/repository-tests'; +import {CrudFeatures, DataSourceOptions} from '@loopback/repository-tests'; const connector = require('loopback-connector-mysql'); @@ -20,7 +17,7 @@ export const MYSQL_CONFIG: DataSourceOptions = { createDatabase: true, }; -export const MYSQL_FEATURES: Partial = { +export const MYSQL_FEATURES: Partial = { idType: 'number', freeFormProperties: false, }; diff --git a/packages/repository-tests/src/crud-test-suite.ts b/packages/repository-tests/src/crud-test-suite.ts index 73f052fe154e..6856b6b04fb0 100644 --- a/packages/repository-tests/src/crud-test-suite.ts +++ b/packages/repository-tests/src/crud-test-suite.ts @@ -9,7 +9,7 @@ import * as fs from 'fs'; import * as path from 'path'; import {withCrudCtx} from './helpers.repository-tests'; import { - CrudConnectorFeatures, + CrudFeatures, CrudRepositoryCtor, CrudTestContext, DataSourceOptions, @@ -20,15 +20,15 @@ const debug = debugFactory('loopback:repository-tests'); type SuiteFn = ( dataSourceOptions: DataSourceOptions, repositoryClass: CrudRepositoryCtor, - connectorFeatures: CrudConnectorFeatures, + connectorFeatures: CrudFeatures, ) => void; export function crudRepositoryTestSuite( dataSourceOptions: DataSourceOptions, repositoryClass: CrudRepositoryCtor, - connectorFeatures: Partial, + connectorFeatures: Partial, ) { - const features: CrudConnectorFeatures = { + const features: CrudFeatures = { idType: 'string', freeFormProperties: true, ...connectorFeatures, diff --git a/packages/repository-tests/src/crud/create-retrieve.suite.ts b/packages/repository-tests/src/crud/create-retrieve.suite.ts index d191282b3702..4699107f6871 100644 --- a/packages/repository-tests/src/crud/create-retrieve.suite.ts +++ b/packages/repository-tests/src/crud/create-retrieve.suite.ts @@ -8,7 +8,7 @@ import {EntityCrudRepository} from '@loopback/repository/src'; import {expect, toJSON} from '@loopback/testlab'; import {withCrudCtx} from '../helpers.repository-tests'; import { - CrudConnectorFeatures, + CrudFeatures, CrudRepositoryCtor, CrudTestContext, DataSourceOptions, @@ -19,7 +19,7 @@ import { export function createRetrieveSuite( dataSourceOptions: DataSourceOptions, repositoryClass: CrudRepositoryCtor, - connectorFeatures: CrudConnectorFeatures, + connectorFeatures: CrudFeatures, ) { @model() class Product extends Entity { diff --git a/packages/repository-tests/src/crud/freeform-properties.suite.ts b/packages/repository-tests/src/crud/freeform-properties.suite.ts index d88cdb2a90c0..b4dbe583bfa7 100644 --- a/packages/repository-tests/src/crud/freeform-properties.suite.ts +++ b/packages/repository-tests/src/crud/freeform-properties.suite.ts @@ -9,7 +9,7 @@ import {expect, skipIf, toJSON} from '@loopback/testlab'; import {Suite} from 'mocha'; import {withCrudCtx} from '../helpers.repository-tests'; import { - CrudConnectorFeatures, + CrudFeatures, CrudRepositoryCtor, CrudTestContext, DataSourceOptions, @@ -18,7 +18,7 @@ import { export function freeformPropertiesSuite( dataSourceOptions: DataSourceOptions, repositoryClass: CrudRepositoryCtor, - connectorFeatures: CrudConnectorFeatures, + connectorFeatures: CrudFeatures, ) { skipIf<[(this: Suite) => void], void>( !connectorFeatures.freeFormProperties, diff --git a/packages/repository-tests/src/types.repository-tests.ts b/packages/repository-tests/src/types.repository-tests.ts index 435d74ee8a04..a8721ac5b1ff 100644 --- a/packages/repository-tests/src/types.repository-tests.ts +++ b/packages/repository-tests/src/types.repository-tests.ts @@ -16,11 +16,11 @@ import { export type DataSourceOptions = Options; /** - * List of flags describing connector-specific behavior. These flags - * are used by the test suite to tweak assertions and skip tests - * for scenarios not supported by some connectors. + * List of flags describing behavior specific to different connectors and + * repository implementations. These flags are used by the test suite to tweak + * assertions and skip tests for scenarios not supported by some implementations. */ -export interface CrudConnectorFeatures { +export interface CrudFeatures { /** * What type is used for auto-generated primary keys? * - SQL databases typically use auto-incremented numbers, @@ -60,6 +60,6 @@ export type CrudRepositoryCtor = new < export interface CrudTestContext { dataSourceOptions: DataSourceOptions; repositoryClass: CrudRepositoryCtor; - connectorFeatures: CrudConnectorFeatures; + connectorFeatures: CrudFeatures; dataSource: juggler.DataSource; } From 4a4e182256c080cc094ed23b1b4f2a5e7b9946e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Mon, 22 Jul 2019 12:05:16 +0200 Subject: [PATCH 2/2] build: add "acceptance" to tsconfig used by VSCode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miroslav Bajtoš --- tsconfig.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tsconfig.json b/tsconfig.json index c6d681524147..3be550426d83 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,12 +1,14 @@ { "extends": "./packages/build/config/tsconfig.common.json", "include": [ + "acceptance", "benchmark", "examples", "packages" ], "exclude": [ "node_modules/**", + "acceptance/node_modules/**", "benchmark/node_modules/**", "examples/*/node_modules/**", "packages/*/node_modules/**",