Skip to content
Merged
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
47 changes: 47 additions & 0 deletions test/operations/schemas/createSchema.spec.ts
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";');
});
});
});
});
});
34 changes: 34 additions & 0 deletions test/operations/schemas/dropPolicy.spec.ts
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;'
);
});
});
});
});
37 changes: 37 additions & 0 deletions test/operations/schemas/renameSchema.spec.ts
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";');
});
});
});
});
});