Skip to content

Commit

Permalink
test: add alter table attribute tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zeruk committed Feb 9, 2023
1 parent ebab692 commit e1de976
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/__tests__/alter-table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Alter table', () => {
const createdTableDescription = await session.describeTable(TABLE_NAME);

expect(createdTableDescription.primaryKey).toStrictEqual(['id']);
expect(JSON.stringify(createdTableDescription.columns)).toStrictEqual(
expect(JSON.stringify(createdTableDescription.columns)).toBe(
JSON.stringify([
{ name: 'id', type: { optionalType: { item: { typeId: 'UINT64' } } } },
{ name: 'title', type: { optionalType: { item: { typeId: 'UTF8' } } } },
Expand Down Expand Up @@ -155,4 +155,31 @@ describe('Alter table', () => {
expect(alteredTableDescription.indexes).toStrictEqual([]);
});
});

// https://ydb.tech/en/docs/yql/reference/syntax/alter_table#additional-alter
it('Alter table - alter - add attribute', async () => {
await driver.tableClient.withSession(async (session) => {
const alterTableDescription = new AlterTableDescription();

alterTableDescription.alterAttributes = { AUTO_PARTITIONING_BY_SIZE: 'DISABLED' };

await session.alterTable(TABLE_NAME, alterTableDescription);
const alteredTableDescription = await session.describeTable(TABLE_NAME);

expect(alteredTableDescription.attributes).toStrictEqual({ AUTO_PARTITIONING_BY_SIZE: 'DISABLED' });
});
});

it('Alter table - alter - remove attribute', async () => {
await driver.tableClient.withSession(async (session) => {
const alterTableDescription = new AlterTableDescription();

alterTableDescription.alterAttributes = { AUTO_PARTITIONING_BY_SIZE: '' };

await session.alterTable(TABLE_NAME, alterTableDescription);
const alteredTableDescription = await session.describeTable(TABLE_NAME);

expect(alteredTableDescription.attributes).toStrictEqual({});
});
});
});

0 comments on commit e1de976

Please sign in to comment.