-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(config): ensure configs without queries are supported
- Loading branch information
1 parent
c4fa727
commit 2b5554f
Showing
13 changed files
with
211 additions
and
25 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const TEST_ASSETS_ROOT_DIR = __dirname; |
6 changes: 6 additions & 0 deletions
6
src/logic/__test_assets__/exampleProject/postgres-noqueries/codegen.sql.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
language: postgres | ||
dialect: 10.7 | ||
resources: | ||
- 'schema/**/*.sql' | ||
generates: | ||
types: src/generated/fromSql/types.ts |
8 changes: 8 additions & 0 deletions
8
...__test_assets__/exampleProject/postgres-noqueries/schema/functions/get_answer_to_life.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CREATE OR REPLACE FUNCTION get_answer_to_life() | ||
RETURNS int | ||
LANGUAGE plpgsql | ||
AS $$ | ||
BEGIN | ||
RETURN 42; | ||
END; | ||
$$ |
9 changes: 9 additions & 0 deletions
9
src/logic/__test_assets__/exampleProject/postgres-noqueries/schema/tables/ice_cream.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE TABLE `ice_cream` ( | ||
`id` bigint(20) NOT NULL AUTO_INCREMENT, | ||
`uuid` char(36) COLLATE utf8mb4_bin NOT NULL, | ||
`created_at` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), | ||
`name` varchar(255) COLLATE utf8mb4_bin NOT NULL, | ||
`ingredient_ids_hash` binary(32) NOT NULL, | ||
PRIMARY KEY (`id`), | ||
UNIQUE KEY `tag_ux1` (`name`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
9 changes: 9 additions & 0 deletions
9
src/logic/__test_assets__/exampleProject/postgres-noqueries/schema/tables/ingredient.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE TABLE ingredient ( | ||
id bigserial PRIMARY KEY, | ||
uuid uuid NOT NULL, | ||
created_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP(6), | ||
name varchar NOT NULL, | ||
cost numeric(5, 2) NOT NULL, | ||
CONSTRAINT ingredient_pk PRIMARY KEY (id), | ||
CONSTRAINT ingredient_ux1 UNIQUE (name) | ||
) |
2 changes: 2 additions & 0 deletions
2
src/logic/__test_assets__/exampleProject/postgres-noqueries/src/generated/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
**/* | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 53 additions & 1 deletion
54
src/logic/config/getConfig/readConfig/__snapshots__/readConfig.integration.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 13 additions & 2 deletions
15
src/logic/config/getConfig/readConfig/readConfig.integration.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,26 @@ | ||
import { GeneratorConfig } from '../../../../domain'; | ||
import { TEST_ASSETS_ROOT_DIR } from '../../../__test_assets__/directory'; | ||
import { readConfig } from './readConfig'; | ||
|
||
describe('readConfig', () => { | ||
it('should be able to read the example config provisioned in __test_assets__', async () => { | ||
it('should be able to read a fully declared config', async () => { | ||
const config = await readConfig({ | ||
filePath: `${__dirname}/../../../__test_assets__/exampleProject/mysql/codegen.sql.yml`, | ||
filePath: `${TEST_ASSETS_ROOT_DIR}/exampleProject/mysql/codegen.sql.yml`, | ||
}); | ||
expect(config).toBeInstanceOf(GeneratorConfig); | ||
expect(config.language).toEqual('mysql'); | ||
expect(config.dialect).toEqual('5.7'); | ||
expect(config.declarations.length).toEqual(12); | ||
expect({ ...config, rootDir: '__DIR__' }).toMatchSnapshot(); // to log an example of the output; note we mask dir to make it machine independent | ||
}); | ||
it('should be able to read a config without queries', async () => { | ||
const config = await readConfig({ | ||
filePath: `${TEST_ASSETS_ROOT_DIR}/exampleProject/postgres-noqueries/codegen.sql.yml`, | ||
}); | ||
expect(config).toBeInstanceOf(GeneratorConfig); | ||
expect(config.language).toEqual('postgres'); | ||
expect(config.dialect).toEqual('10.7'); | ||
expect(config.declarations.length).toEqual(3); | ||
expect({ ...config, rootDir: '__DIR__' }).toMatchSnapshot(); // to log an example of the output; note we mask dir to make it machine independent | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters