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..d1ab935d6e6c 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,18 +20,19 @@ const debug = debugFactory('loopback:repository-tests'); type SuiteFn = ( dataSourceOptions: DataSourceOptions, repositoryClass: CrudRepositoryCtor, - connectorFeatures: CrudConnectorFeatures, + features: CrudFeatures, ) => void; export function crudRepositoryTestSuite( dataSourceOptions: DataSourceOptions, repositoryClass: CrudRepositoryCtor, - connectorFeatures: Partial, + partialFeatures: Partial, ) { - const features: CrudConnectorFeatures = { + const features: CrudFeatures = { idType: 'string', freeFormProperties: true, - ...connectorFeatures, + inclusionResolvers: true, + ...partialFeatures, }; describe('CRUD Repository operations', () => { @@ -39,7 +40,7 @@ export function crudRepositoryTestSuite( withCrudCtx(function setupContext(ctx: CrudTestContext) { ctx.dataSourceOptions = dataSourceOptions; ctx.repositoryClass = repositoryClass; - ctx.connectorFeatures = features; + ctx.features = features; }), ); before( @@ -70,7 +71,7 @@ export function crudRepositoryTestSuite( suite.name, dataSourceOptions, 'class ' + repositoryClass.name, - connectorFeatures, + features, ); suite(dataSourceOptions, repositoryClass, features); } diff --git a/packages/repository-tests/src/crud/create-retrieve.suite.ts b/packages/repository-tests/src/crud/create-retrieve.suite.ts index d191282b3702..3b8cf9c102bd 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,12 +19,12 @@ import { export function createRetrieveSuite( dataSourceOptions: DataSourceOptions, repositoryClass: CrudRepositoryCtor, - connectorFeatures: CrudConnectorFeatures, + features: CrudFeatures, ) { @model() class Product extends Entity { @property({ - type: connectorFeatures.idType, + type: features.idType, id: true, generated: true, description: 'The unique identifier for a product', diff --git a/packages/repository-tests/src/crud/freeform-properties.suite.ts b/packages/repository-tests/src/crud/freeform-properties.suite.ts index d88cdb2a90c0..a821bfa243a7 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,17 +18,17 @@ import { export function freeformPropertiesSuite( dataSourceOptions: DataSourceOptions, repositoryClass: CrudRepositoryCtor, - connectorFeatures: CrudConnectorFeatures, + features: CrudFeatures, ) { skipIf<[(this: Suite) => void], void>( - !connectorFeatures.freeFormProperties, + !features.freeFormProperties, describe, 'free-form properties (strict: false)', () => { @model({settings: {strict: false}}) class Freeform extends Entity { @property({ - type: connectorFeatures.idType, + type: features.idType, id: true, description: 'The unique identifier for a product', }) diff --git a/packages/repository-tests/src/types.repository-tests.ts b/packages/repository-tests/src/types.repository-tests.ts index 435d74ee8a04..189f4c3955c2 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 a connector and a repository + * class being tested. These flags are used by the test suite to tweak + * assertions and skip tests for scenarios not supported by some connectors. */ -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; + features: CrudFeatures; dataSource: juggler.DataSource; }