-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add schemas unit tests (#1030)
- Loading branch information
1 parent
3a631b0
commit a5b2f36
Showing
3 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
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,47 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { createSchema } from '../../../src/operations/schemas'; | ||
import { options1 } from '../../utils'; | ||
|
||
describe('operations', () => { | ||
describe('schemas', () => { | ||
describe('createSchema', () => { | ||
const createSchemaFn = createSchema(options1); | ||
|
||
it('should return a function', () => { | ||
expect(createSchemaFn).toBeTypeOf('function'); | ||
}); | ||
|
||
it('should return sql statement', () => { | ||
const statement = createSchemaFn('myschema'); | ||
|
||
expect(statement).toBeTypeOf('string'); | ||
expect(statement).toStrictEqual('CREATE SCHEMA "myschema";'); | ||
}); | ||
|
||
it('should return sql statement with schemaOptions', () => { | ||
const statement = createSchemaFn('test', { | ||
ifNotExists: true, | ||
authorization: 'joe', | ||
}); | ||
|
||
expect(statement).toBeTypeOf('string'); | ||
expect(statement).toStrictEqual( | ||
'CREATE SCHEMA IF NOT EXISTS "test" AUTHORIZATION joe;' | ||
); | ||
}); | ||
|
||
describe('reverse', () => { | ||
it('should contain a reverse function', () => { | ||
expect(createSchemaFn.reverse).toBeTypeOf('function'); | ||
}); | ||
|
||
it('should return sql statement', () => { | ||
const statement = createSchemaFn.reverse('myschema'); | ||
|
||
expect(statement).toBeTypeOf('string'); | ||
expect(statement).toBe('DROP SCHEMA "myschema";'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
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,34 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { dropSchema } from '../../../src/operations/schemas'; | ||
import { options1 } from '../../utils'; | ||
|
||
describe('operations', () => { | ||
describe('schemas', () => { | ||
describe('dropSchema', () => { | ||
const dropSchemaFn = dropSchema(options1); | ||
|
||
it('should return a function', () => { | ||
expect(dropSchemaFn).toBeTypeOf('function'); | ||
}); | ||
|
||
it('should return sql statement', () => { | ||
const statement = dropSchemaFn('mystuff'); | ||
|
||
expect(statement).toBeTypeOf('string'); | ||
expect(statement).toStrictEqual('DROP SCHEMA "mystuff";'); | ||
}); | ||
|
||
it('should return sql statement with dropOptions', () => { | ||
const statement = dropSchemaFn('mystuff', { | ||
ifExists: true, | ||
cascade: true, | ||
}); | ||
|
||
expect(statement).toBeTypeOf('string'); | ||
expect(statement).toStrictEqual( | ||
'DROP SCHEMA IF EXISTS "mystuff" CASCADE;' | ||
); | ||
}); | ||
}); | ||
}); | ||
}); |
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,37 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { renameSchema } from '../../../src/operations/schemas'; | ||
import { options1 } from '../../utils'; | ||
|
||
describe('operations', () => { | ||
describe('schemas', () => { | ||
describe('renameSchema', () => { | ||
const renameSchemaFn = renameSchema(options1); | ||
|
||
it('should return a function', () => { | ||
expect(renameSchemaFn).toBeTypeOf('function'); | ||
}); | ||
|
||
it('should return sql statement', () => { | ||
const statement = renameSchemaFn('test', 'myschema'); | ||
|
||
expect(statement).toBeTypeOf('string'); | ||
expect(statement).toStrictEqual( | ||
'ALTER SCHEMA "test" RENAME TO "myschema";' | ||
); | ||
}); | ||
|
||
describe('reverse', () => { | ||
it('should contain a reverse function', () => { | ||
expect(renameSchemaFn.reverse).toBeTypeOf('function'); | ||
}); | ||
|
||
it('should return sql statement', () => { | ||
const statement = renameSchemaFn.reverse('test', 'myschema'); | ||
|
||
expect(statement).toBeTypeOf('string'); | ||
expect(statement).toBe('ALTER SCHEMA "myschema" RENAME TO "test";'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |