Skip to content

Commit

Permalink
add introspection engine tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timsuchanek committed Dec 4, 2019
1 parent 9a67ea2 commit 1c72bad
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
1 change: 0 additions & 1 deletion cli/sdk/src/IntrospectionEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ export class IntrospectionEngine {
await this.init()
return new Promise((resolve, reject) => {
this.registerCallback(request.id, (response, err) => {
console.log(response)
if (err) {
return reject(err)
}
Expand Down
Binary file modified cli/sdk/src/__tests__/introspection/blog.db
Binary file not shown.
43 changes: 31 additions & 12 deletions cli/sdk/src/__tests__/introspection/introspection.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
// import { IntrospectionEngine } from '../../IntrospectionEngine'
import { IntrospectionEngine } from '../../IntrospectionEngine'
import path from 'path'

// async function main() {
// const engine = new IntrospectionEngine({
// cwd: __dirname,
// })
test('basic introspection', async () => {
const engine = new IntrospectionEngine({
cwd: __dirname,
})

// const result = await engine.introspect('file:blog.db')
// console.log(JSON.stringify(result))
// }
const result = await engine.introspect(
`file:${path.resolve(__dirname, 'blog.db')}`,
)
expect(result).toMatchInlineSnapshot(`
"model User {
age Int @default(0)
amount Float @default(0)
balance Float @default(0)
email String @default(\\"''\\") @unique
id Int @id
name String?
role String @default(\\"'USER'\\")
posts Post[]
}
// main()

test('introspection', () => {
expect(1).toBe(1)
model Post {
author User
content String?
createdAt DateTime
kind String?
published Boolean @default(false)
title String @default(\\"''\\")
updatedAt DateTime
uuid String @id(strategy: NONE)
}"
`)
})
1 change: 1 addition & 0 deletions cli/sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { IntrospectionEngine } from './IntrospectionEngine'
export { Generator } from './Generator'
export { getGenerators, getGenerator, ProviderAliases } from './getGenerators'
export { isdlToDatamodel2 } from './isdlToDatamodel2'
Expand Down

0 comments on commit 1c72bad

Please sign in to comment.