Skip to content

Commit 84da060

Browse files
ft.alter
1 parent 7110f23 commit 84da060

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { strict as assert } from 'assert';
2+
import testUtils, { GLOBAL } from '../test-utils';
3+
import { transformArguments } from './ALTER';
4+
import { SchemaFieldTypes } from './CREATE';
5+
6+
describe('ALTER', () => {
7+
describe('transformArguments', () => {
8+
it('with NOINDEX', () => {
9+
assert.deepEqual(
10+
transformArguments('index', {
11+
field: {
12+
type: SchemaFieldTypes.TEXT,
13+
NOINDEX: true,
14+
SORTABLE: 'UNF',
15+
AS: 'text'
16+
}
17+
}),
18+
['FT.ALTER', 'index', 'SCHEMA', 'ADD', 'field', 'AS', 'text', 'TEXT', 'SORTABLE', 'UNF', 'NOINDEX']
19+
);
20+
});
21+
});
22+
23+
testUtils.testWithClient('client.ft.create', async client => {
24+
await Promise.all([
25+
client.ft.create('index', {
26+
title: SchemaFieldTypes.TEXT
27+
}),
28+
]);
29+
30+
assert.equal(
31+
await client.ft.alter('index', {
32+
body: SchemaFieldTypes.TEXT
33+
}),
34+
'OK'
35+
);
36+
}, GLOBAL.SERVERS.OPEN);
37+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { CreateSchema, pushSchema } from './CREATE';
2+
3+
export function transformArguments(index: string, schema: CreateSchema): Array<string> {
4+
const args = ['FT.ALTER', index, 'SCHEMA', 'ADD'];
5+
pushSchema(args, schema);
6+
7+
return args;
8+
}
9+
10+
export declare function transformReply(): 'OK';

0 commit comments

Comments
 (0)