Skip to content

Commit

Permalink
refactor: restructure tests and fix typings reference path in source …
Browse files Browse the repository at this point in the history
…code

Tests needs to be scoped properly, since they are growing in number
  • Loading branch information
thetutlage committed Sep 30, 2019
1 parent ee75a1d commit 17ed065
Show file tree
Hide file tree
Showing 18 changed files with 56 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/Connection/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/

/// <reference path="../../adonis-typings/database.ts" />
/// <reference path="../../adonis-typings/index.ts" />

import { EventEmitter } from 'events'
import { Exception } from '@poppinss/utils'
Expand Down
2 changes: 1 addition & 1 deletion src/Connection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/

/// <reference path="../../adonis-typings/database.ts" />
/// <reference path="../../adonis-typings/index.ts" />

import knex from 'knex'
import { Pool } from 'tarn'
Expand Down
2 changes: 1 addition & 1 deletion src/Database/QueryBuilder/Chainable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/

/// <reference path="../../../adonis-typings/database.ts" />
/// <reference path="../../../adonis-typings/index.ts" />

import knex from 'knex'
import { ChainableContract, QueryCallback } from '@ioc:Adonis/Lucid/DatabaseQueryBuilder'
Expand Down
2 changes: 1 addition & 1 deletion src/Database/QueryBuilder/Database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/

/// <reference path="../../../adonis-typings/database.ts" />
/// <reference path="../../../adonis-typings/index.ts" />

import knex from 'knex'
import { trait } from '@poppinss/traits'
Expand Down
2 changes: 1 addition & 1 deletion src/Database/QueryBuilder/Insert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/

/// <reference path="../../../adonis-typings/database.ts" />
/// <reference path="../../../adonis-typings/index.ts" />

import knex from 'knex'
import { trait } from '@poppinss/traits'
Expand Down
2 changes: 1 addition & 1 deletion src/Database/QueryBuilder/Raw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/

/// <reference path="../../../adonis-typings/database.ts" />
/// <reference path="../../../adonis-typings/index.ts" />

import knex from 'knex'
import { trait } from '@poppinss/traits'
Expand Down
2 changes: 1 addition & 1 deletion src/Database/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* file that was distributed with this source code.
*/

/// <reference path="../../adonis-typings/database.ts" />
/// <reference path="../../adonis-typings/index.ts" />

import { Exception } from '@poppinss/utils'
import { LoggerContract } from '@ioc:Adonis/Core/Logger'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
* file that was distributed with this source code.
*/

/// <reference path="../adonis-typings/database.ts" />
/// <reference path="../../adonis-typings/index.ts" />

import test from 'japa'

import { ConnectionManager } from '../src/Connection/Manager'
import { getConfig, setup, cleanup, getLogger } from '../test-helpers'
import { ConnectionManager } from '../../src/Connection/Manager'
import { getConfig, setup, cleanup, getLogger } from '../../test-helpers'

test.group('ConnectionManager', (group) => {
group.before(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
* file that was distributed with this source code.
*/

/// <reference path="../adonis-typings/database.ts" />
/// <reference path="../../adonis-typings/index.ts" />

import test from 'japa'
import { MysqlConfigContract } from '@ioc:Adonis/Lucid/Database'

import { Connection } from '../src/Connection'
import { getConfig, setup, cleanup, resetTables, getLogger } from '../test-helpers'
import { Connection } from '../../src/Connection'
import { getConfig, setup, cleanup, resetTables, getLogger } from '../../test-helpers'

if (process.env.DB !== 'sqlite') {
test.group('Connection | config', (group) => {
Expand Down
6 changes: 3 additions & 3 deletions test/database.spec.ts → test/database/database.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
* file that was distributed with this source code.
*/

/// <reference path="../adonis-typings/database.ts" />
/// <reference path="../../adonis-typings/index.ts" />

import test from 'japa'

import { Database } from '../src/Database'
import { getConfig, setup, cleanup, getLogger, getProfiler } from '../test-helpers'
import { Database } from '../../src/Database'
import { getConfig, setup, cleanup, getLogger, getProfiler } from '../../test-helpers'

test.group('Database', (group) => {
group.before(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
* file that was distributed with this source code.
*/

/// <reference path="../adonis-typings/database.ts" />
/// <reference path="../../adonis-typings/index.ts" />

import test from 'japa'

import { Connection } from '../src/Connection'
import { getConfig, setup, cleanup, getInsertBuilder, getLogger, getQueryClient } from '../test-helpers'
import { Connection } from '../../src/Connection'
import { getConfig, setup, cleanup, getInsertBuilder, getLogger, getQueryClient } from '../../test-helpers'

test.group('Query Builder | insert', (group) => {
group.before(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
* file that was distributed with this source code.
*/

/// <reference path="../adonis-typings/database.ts" />
/// <reference path="../../adonis-typings/index.ts" />

import test from 'japa'
import { Connection } from '../src/Connection'
import { DatabaseQueryBuilder } from '../src/Database/QueryBuilder/Database'
import { Connection } from '../../src/Connection'
import { DatabaseQueryBuilder } from '../../src/Database/QueryBuilder/Database'
import {
setup,
cleanup,
Expand All @@ -21,7 +21,7 @@ import {
getQueryBuilder,
getInsertBuilder,
getRawQueryBuilder,
} from '../test-helpers'
} from '../../test-helpers'

if (process.env.DB !== 'sqlite') {
test.group('Query Builder | client', (group) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
* file that was distributed with this source code.
*/

/// <reference path="../adonis-typings/database.ts" />
/// <reference path="../../adonis-typings/index.ts" />

import test from 'japa'
import { Connection } from '../src/Connection'
import { QueryClient } from '../src/QueryClient'
import { getConfig, setup, cleanup, getLogger } from '../test-helpers'
import { Connection } from '../../src/Connection'
import { QueryClient } from '../../src/QueryClient'
import { getConfig, setup, cleanup, getLogger } from '../../test-helpers'

test.group('Query client', (group) => {
group.before(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
* file that was distributed with this source code.
*/

/// <reference path="../adonis-typings/database.ts" />
/// <reference path="../../adonis-typings/index.ts" />

import test from 'japa'

import { Connection } from '../src/Connection'
import { QueryClient } from '../src/QueryClient'
import { getConfig, setup, cleanup, resetTables, getLogger } from '../test-helpers'
import { Connection } from '../../src/Connection'
import { QueryClient } from '../../src/QueryClient'
import { getConfig, setup, cleanup, resetTables, getLogger } from '../../test-helpers'

test.group('Transaction | query', (group) => {
group.before(async () => {
Expand Down
6 changes: 4 additions & 2 deletions test/adapter.spec.ts → test/orm/adapter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
* file that was distributed with this source code.
*/

/// <reference path="../../adonis-typings/index.ts" />

import test from 'japa'
import { column } from '../src/Orm/Decorators'
import { setup, cleanup, getDb, resetTables, getBaseModel, ormAdapter } from '../test-helpers'
import { column } from '../../src/Orm/Decorators'
import { setup, cleanup, getDb, resetTables, getBaseModel, ormAdapter } from '../../test-helpers'

test.group('Adapter', (group) => {
group.before(async () => {
Expand Down
7 changes: 4 additions & 3 deletions test/base-model.spec.ts → test/orm/base-model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
* file that was distributed with this source code.
*/

import test from 'japa'
/// <reference path="../../adonis-typings/index.ts" />

import { column, computed, hasOne } from '../src/Orm/Decorators'
import { FakeAdapter, getBaseModel, ormAdapter, mapToObj } from '../test-helpers'
import test from 'japa'
import { column, computed, hasOne } from '../../src/Orm/Decorators'
import { FakeAdapter, getBaseModel, ormAdapter, mapToObj } from '../../test-helpers'

test.group('Base model | boot', () => {
test('compute table name from model name', async (assert) => {
Expand Down
6 changes: 4 additions & 2 deletions test/model-has-one.spec.ts → test/orm/model-has-one.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
* file that was distributed with this source code.
*/

/// <reference path="../../adonis-typings/index.ts" />

import test from 'japa'
import { column, hasOne } from '../src/Orm/Decorators'
import { ormAdapter, getBaseModel, setup, cleanup, resetTables, getDb } from '../test-helpers'
import { column, hasOne } from '../../src/Orm/Decorators'
import { ormAdapter, getBaseModel, setup, cleanup, resetTables, getDb } from '../../test-helpers'

test.group('Model | Has one', (group) => {
group.before(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@
* file that was distributed with this source code.
*/

/// <reference path="../../adonis-typings/index.ts" />

import test from 'japa'
import { column } from '../src/Orm/Decorators'
import { ModelQueryBuilder } from '../src/Orm/QueryBuilder'
import { getBaseModel, ormAdapter, getDb, setup, cleanup, resetTables, getProfiler } from '../test-helpers'
import { column } from '../../src/Orm/Decorators'
import { ModelQueryBuilder } from '../../src/Orm/QueryBuilder'
import {
getDb,
setup,
cleanup,
ormAdapter,
resetTables,
getProfiler,
getBaseModel,
} from '../../test-helpers'

test.group('Model query builder', (group) => {
group.before(async () => {
Expand Down

0 comments on commit 17ed065

Please sign in to comment.