Skip to content

Commit 3af73eb

Browse files
refactor: move seed data to database/seeds/data
1 parent 5cae171 commit 3af73eb

18 files changed

+36
-31
lines changed

.jest/globalSetup.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
import * as dotenv from 'dotenv';
22
dotenv.config();
3-
import exampleTree from '../docs/api/spec/examples/trees/exampleTree.json';
4-
import exampleWallet from '../docs/api/spec/examples/wallets/exampleWallet.json';
5-
import exampleSpecies from '../docs/api/spec/examples/species/exampleSpecies.json';
6-
import examplePlanter from '../docs/api/spec/examples/planters/examplePlanter.json';
7-
import exampleCountry from '../docs/api/spec/examples/countries/exampleCountry.json';
8-
import exampleOrganization from '../docs/api/spec/examples/organizations/exampleOrganization.json';
9-
import exampleToken from '../docs/api/spec/examples/tokens/exampleToken.json';
10-
import knex, { TableNames } from '../server/infra/database/knex';
3+
import 'tsconfig-paths/register';
4+
import tree from '@seeds/data/tree.json';
5+
import wallet from '@seeds/data/wallet.json';
6+
import species from '@seeds/data/species.json';
7+
import planter from '@seeds/data/planter.json';
8+
import country from '@seeds/data/country.json';
9+
import organization from '@seeds/data/organization.json';
10+
import token from '@seeds/data/token.json';
11+
import knex, { TableNames } from 'infra/database/knex';
1112

1213
export default async function globalSetup() {
1314
if (process.env.SEED === 'true') {
14-
await knex(TableNames.Trees).insert(exampleTree);
15-
await knex('wallet').withSchema('wallet').insert(exampleWallet);
16-
await knex('token').withSchema('wallet').insert(exampleToken);
17-
await knex(TableNames.Species).insert(exampleSpecies);
18-
await knex(TableNames.Organizations).insert(exampleOrganization);
19-
await knex(TableNames.Planters).insert(examplePlanter);
15+
await knex(TableNames.Trees).insert(tree);
16+
await knex('wallet').withSchema('wallet').insert(wallet);
17+
await knex('token').withSchema('wallet').insert(token);
18+
await knex(TableNames.Species).insert(species);
19+
await knex(TableNames.Organizations).insert(organization);
20+
await knex(TableNames.Planters).insert(planter);
2021
await knex('region_type').insert({
2122
id: 6,
2223
type: 'country',
2324
});
24-
await knex(TableNames.Countries).insert(exampleCountry);
25-
25+
await knex(TableNames.Countries).insert(country);
2626
}
2727
knex.destroy();
2828
}

__tests__/e2e/countries.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import exampleCountry from '@mocks/countries/exampleCountry.json';
1+
import exampleCountry from '@seeds/data/country.json';
22
import supertest from 'supertest';
33
import app from 'app';
44

__tests__/e2e/organizations.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import exampleOrganization from '@mocks/organizations/exampleOrganization.json';
2-
import examplePlanter from '@mocks/planters/examplePlanter.json';
1+
import exampleOrganization from '@seeds/data/organization.json';
2+
import examplePlanter from '@seeds/data/planter.json';
33
import supertest from 'supertest';
44
import app from 'app';
55

__tests__/e2e/planters.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import exampleOrganization from '@mocks/organizations/exampleOrganization.json';
2-
import examplePlanter from '@mocks/planters/examplePlanter.json';
1+
import exampleOrganization from '@seeds/data/organization.json';
2+
import examplePlanter from '@seeds/data/planter.json';
33
import supertest from 'supertest';
44
import app from 'app';
55

__tests__/e2e/species.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import exampleOrganizations from '@mocks/organizations/exampleOrganization.json';
2-
import examplePlanter from '@mocks/planters/examplePlanter.json';
3-
import exampleSpecies from '@mocks/species/exampleSpecies.json';
1+
import exampleOrganization from '@seeds/data/organization.json';
2+
import examplePlanter from '@seeds/data/planter.json';
3+
import exampleSpecies from '@seeds/data/species.json';
44
import supertest from 'supertest';
55
import app from 'app';
66

@@ -17,7 +17,7 @@ it(
1717
'species?organization_id=1&limit=1',
1818
async () => {
1919
const response = await supertest(app).get(
20-
`/species?organization_id=${exampleOrganizations.id}&limit=1`,
20+
`/species?organization_id=${exampleOrganization.id}&limit=1`,
2121
);
2222
expect(response.status).toBe(200);
2323
expect(response.body.species).toBeInstanceOf(Array);

__tests__/e2e/tokens.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import exampleToken from '@mocks/tokens/exampleToken.json';
1+
import exampleToken from '@seeds/data/token.json';
22
import supertest from 'supertest';
33
import app from 'app';
44

__tests__/e2e/trees.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import exampleOrganization from '@mocks/organizations/exampleOrganization.json';
2-
import exampleTree from '@mocks/trees/exampleTree.json';
1+
import exampleOrganization from '@seeds/data/organization.json';
2+
import exampleTree from '@seeds/data/tree.json';
33
import supertest from 'supertest';
44
import app from 'app';
55

__tests__/e2e/wallets.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import exampleWallet from '@mocks/wallets/exampleWallet.json';
1+
import exampleWallet from '@seeds/data/wallet.json';
22
import supertest from 'supertest';
3-
import app from '../../server/app';
3+
import app from 'app';
44

55
it('get wallet by id or name', async () => {
66
const { id, name } = exampleWallet;

0 commit comments

Comments
 (0)