Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,348 changes: 1,347 additions & 1 deletion package-lock.json

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@
"cli": "tsx src/codegen/cli.ts",
"cli:index": "tsx src/codegen/cli.ts --onlyindex true",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --config .eslintrc.lint.cjs",
"lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix --config .eslintrc.lint.cjs",
"lint:fix": "eslint \"{src,apps,libs,tests}/**/*.ts\" --fix --config .eslintrc.lint.cjs",
"lint:types": "tsc --pretty --noEmit",
"lint:all": "npm run lint:fix && npm run lint:types"
"lint:all": "npm run lint:fix && npm run lint:types",
"test": "vitest run",
"test:watch": "vitest dev",
"test:ui": "vitest dev --ui"
},
"license": "Apache-2.0",
"author": {
Expand Down Expand Up @@ -82,13 +85,15 @@
"@types/to-json-schema": "0.2.1",
"@typescript-eslint/eslint-plugin": "5.57.0",
"@typescript-eslint/parser": "5.57.0",
"@vitest/ui": "^0.29.8",
"eslint": "8.37.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-unused-imports": "2.0.0",
"prettier": "2.8.7",
"prompts": "2.4.2",
"tsx": "3.12.6",
"typescript": "4.9.5"
"typescript": "4.9.5",
"vitest": "^0.29.8"
}
}
2 changes: 1 addition & 1 deletion src/codegen/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const prepare = async (schema: string, tableName: string) => {
}
}

const getSchemaTableColumns = async (
export const getSchemaTableColumns = async (
schema: string,
tableName: string,
): Promise<SchemaTableColumn[]> => {
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const generateModel = ({
return models
}

const convertField = ({
export const convertField = ({
fieldName,
fieldDefinition,
parent,
Expand Down
51 changes: 51 additions & 0 deletions tests/codegen/__snapshots__/generator.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Codegen - Generator > getSchemaTableColumns 1`] = `
[
{
"description": "",
"name": "stringarray",
"type": "array(varchar)",
},
{
"description": "",
"name": "stringfield",
"type": "varchar",
},
{
"description": "",
"name": "booleanfield",
"type": "boolean",
},
{
"description": "",
"name": "datetimefield",
"type": "timestamp(3)",
},
{
"description": "",
"name": "bigintfield",
"type": "bigint",
},
{
"description": "",
"name": "simpleobject",
"type": "row(sosub1 varchar, sosub2 bigint)",
},
{
"description": "",
"name": "complexobject",
"type": "row(cosub1 varchar, cosub2 array(varchar), cosub3 array(row(cosub31 varchar, cosub32 varchar)))",
},
{
"description": "",
"name": "dash-field",
"type": "varchar",
},
{
"description": "",
"name": "special-aou",
"type": "varchar",
},
]
`;
21 changes: 21 additions & 0 deletions tests/codegen/generator.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expect, test, describe, vi } from 'vitest'
import { getSchemaTableColumns } from '../../src/codegen/generator'
import { sqlTableColumns } from '../mockdata'

describe('Codegen - Generator', () => {
test('getSchemaTableColumns', async () => {
const fnResult = await getSchemaTableColumns('testSchema', 'testTable')
expect(fnResult).toMatchSnapshot()
})
})

//Mock the Presto Client
vi.mock('src/client/sql-client', () => {
const SqlClient = vi.fn()
SqlClient.prototype.query = vi.fn(async () => {
return sqlTableColumns
})
SqlClient.prototype.end = vi.fn()

return { SqlClient }
})
Loading