Skip to content

Commit 49dfc83

Browse files
committed
🎉 prettier
1 parent bbf9369 commit 49dfc83

6 files changed

Lines changed: 86 additions & 71 deletions

File tree

__tests__/ddl.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { getDBConfig, getSpace } from './utils'
2-
import { QueryResult, SQParam } from '../src/skytable'
1+
import { getDBConfig, getSpace } from './utils';
2+
import { QueryResult, SQParam } from '../src/skytable';
33

44
const testSpace = 'ddltestspace';
55

@@ -8,12 +8,12 @@ describe('DDL', () => {
88
const dbConfig = getDBConfig();
99

1010
beforeAll(async () => {
11-
db = await dbConfig.connect()
12-
})
11+
db = await dbConfig.connect();
12+
});
1313

1414
afterAll(async () => {
15-
dbConfig.disconnect()
16-
})
15+
dbConfig.disconnect();
16+
});
1717

1818
it('CREATE SPACE', async () => {
1919
const spaceName = `${testSpace + Date.now()}`;
@@ -22,7 +22,7 @@ describe('DDL', () => {
2222
} finally {
2323
await db.query(`DROP SPACE ALLOW NOT EMPTY ${spaceName}`);
2424
}
25-
})
25+
});
2626

2727
// FIXME need to fix
2828
// it('ALTER SPACE', async () => {
@@ -39,4 +39,4 @@ describe('DDL', () => {
3939
// await db.query(`DROP SPACE ALLOW NOT EMPTY ${spaceName}`);
4040
// }
4141
// })
42-
})
42+
});

__tests__/dml.spec.ts

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,93 @@
1-
import { getDBConfig, getTable } from './utils'
1+
import { getDBConfig, getTable } from './utils';
22

33
describe('DML', () => {
44
let db: any;
55
const dbConfig = getDBConfig();
66

77
beforeAll(async () => {
8-
db = await dbConfig.connect()
9-
})
8+
db = await dbConfig.connect();
9+
});
1010

1111
afterAll(async () => {
12-
dbConfig.disconnect()
13-
})
12+
dbConfig.disconnect();
13+
});
1414

1515
it('null type', async () => {
1616
const [tableName, drop] = await getTable(db);
1717
try {
18-
await db.query(`CREATE MODEL ${tableName}(username: string, null email_id: string)`)
19-
20-
await db.query(`INSERT INTO ${tableName}(?, ?)`, 'test', null)
21-
22-
expect(await db.query(`SELECT username,email_id FROM ${tableName} WHERE username = ?`, 'test')).toEqual(
23-
['test', null]
24-
)
25-
18+
await db.query(
19+
`CREATE MODEL ${tableName}(username: string, null email_id: string)`,
20+
);
21+
22+
await db.query(`INSERT INTO ${tableName}(?, ?)`, 'test', null);
23+
24+
expect(
25+
await db.query(
26+
`SELECT username,email_id FROM ${tableName} WHERE username = ?`,
27+
'test',
28+
),
29+
).toEqual(['test', null]);
2630
} finally {
27-
await drop()
31+
await drop();
2832
}
29-
})
33+
});
3034

3135
it('int number type', async () => {
3236
const [tableName, drop] = await getTable(db);
3337

3438
try {
35-
await db.query(`CREATE MODEL ${tableName}(u8: uint8, u16: uint16, u32: uint32, u64: uint64)`)
39+
await db.query(
40+
`CREATE MODEL ${tableName}(u8: uint8, u16: uint16, u32: uint32, u64: uint64)`,
41+
);
42+
43+
await db.query(
44+
`INSERT INTO ${tableName}(?, ?, ?, ?)`,
45+
1,
46+
2,
47+
3312321,
48+
BigInt(478787872837218382),
49+
);
3650

37-
await db.query(`INSERT INTO ${tableName}(?, ?, ?, ?)`, 1, 2, 3312321, BigInt(478787872837218382))
38-
3951
// TODO why is the uint8 in bigint
40-
expect(await db.query(`SELECT * FROM ${tableName} WHERE u8 = ?`, 1)).toEqual(
41-
[BigInt(1), 2, 3312321, BigInt(478787872837218382)]
42-
)
52+
expect(
53+
await db.query(`SELECT * FROM ${tableName} WHERE u8 = ?`, 1),
54+
).toEqual([BigInt(1), 2, 3312321, BigInt(478787872837218382)]);
4355
} finally {
4456
await drop();
4557
}
46-
})
58+
});
4759

4860
it('list type', async () => {
4961
const [tableName, drop] = await getTable(db);
5062

5163
try {
52-
await db.query(`CREATE MODEL ${tableName}(id: uint64, list: list { type: string} )`)
64+
await db.query(
65+
`CREATE MODEL ${tableName}(id: uint64, list: list { type: string} )`,
66+
);
5367

54-
await db.query(`INSERT INTO ${tableName}(?, [?])`, 1, 'test')
68+
await db.query(`INSERT INTO ${tableName}(?, [?])`, 1, 'test');
5569

56-
expect(await db.query(`SELECT * FROM ${tableName} WHERE id = ?`, 1)).toEqual(
57-
[BigInt(1), ['test']]
58-
)
70+
expect(
71+
await db.query(`SELECT * FROM ${tableName} WHERE id = ?`, 1),
72+
).toEqual([BigInt(1), ['test']]);
5973
} finally {
6074
await drop();
6175
}
62-
})
76+
});
6377

6478
it('list type', async () => {
6579
const [tableName, drop] = await getTable(db);
6680

6781
try {
68-
await db.query(`CREATE MODEL ${tableName}(id: uint64, binary: binary )`)
82+
await db.query(`CREATE MODEL ${tableName}(id: uint64, binary: binary )`);
6983

70-
await db.query(`INSERT INTO ${tableName}(?, ?)`, 1, Buffer.from('test'))
84+
await db.query(`INSERT INTO ${tableName}(?, ?)`, 1, Buffer.from('test'));
7185

72-
expect(await db.query(`SELECT * FROM ${tableName} WHERE id = ?`, 1)).toEqual(
73-
[BigInt(1), Buffer.from('test')]
74-
)
86+
expect(
87+
await db.query(`SELECT * FROM ${tableName} WHERE id = ?`, 1),
88+
).toEqual([BigInt(1), Buffer.from('test')]);
7589
} finally {
7690
await drop();
7791
}
78-
})
79-
});
92+
});
93+
});

__tests__/utils.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
import { Config } from "../src";
1+
import { Config } from '../src';
22

33
export function getDBConfig() {
4-
return new Config(
5-
'root',
6-
'admin123456123456',
7-
'127.0.0.1',
8-
2003
9-
);
4+
return new Config('root', 'admin123456123456', '127.0.0.1', 2003);
105
}
116

12-
export async function getSpace(db: any, space = 'testspace'): Promise<[string, Function]> {
7+
export async function getSpace(
8+
db: any,
9+
space = 'testspace',
10+
): Promise<[string, Function]> {
1311
await db.query(`CREATE SPACE IF NOT EXISTS ${space}`);
1412

1513
await db.query(`USE ${space}`);
1614

17-
return [space, async () => await db.query(`DROP SPACE ALLOW NOT EMPTY ${space}`)];
15+
return [
16+
space,
17+
async () => await db.query(`DROP SPACE ALLOW NOT EMPTY ${space}`),
18+
];
1819
}
1920

2021
export async function getTable(db: any): Promise<[string, Function]> {

examples/test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
import { Row } from './../src/skytable';
2-
import { Config } from "../src"
2+
import { Config } from '../src';
33

44
async function test() {
5-
const config = new Config(
6-
'root',
7-
'admin123456123456',
8-
'127.0.0.1',
9-
2003
10-
)
5+
const config = new Config('root', 'admin123456123456', '127.0.0.1', 2003);
116
const spaceName = `testTable${Date.now()}Space`;
127
const tableName = `${spaceName}.testTable`;
13-
const db = await config.connect()
8+
const db = await config.connect();
149

1510
try {
16-
await db.query('create space ' + spaceName)
17-
await db.query('use ' + spaceName)
18-
await db.query(`CREATE MODEL ${tableName}(username: string, password: string, null email_id: string)`)
11+
await db.query('create space ' + spaceName);
12+
await db.query('use ' + spaceName);
13+
await db.query(
14+
`CREATE MODEL ${tableName}(username: string, password: string, null email_id: string)`,
15+
);
1916
await db.query(
2017
`INSERT INTO ${tableName}(?, ?, ?)`,
2118
'test',
2219
'password',
23-
null
24-
)
25-
const row = await db.query(`SELECT * FROM ${tableName} WHERE username = ?`, 'test')
26-
const [username, password, email_id] = (row as Row);
20+
null,
21+
);
22+
const row = await db.query(
23+
`SELECT * FROM ${tableName} WHERE username = ?`,
24+
'test',
25+
);
26+
const [username, password, email_id] = row as Row;
2727
console.assert(username === 'test');
2828
console.assert(password === 'password');
2929
console.assert(email_id == null);
@@ -32,4 +32,4 @@ async function test() {
3232
}
3333
}
3434

35-
test()
35+
test();

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"build": "tsc",
1616
"debugger": "npx tsx examples/test.ts",
1717
"test": "jest",
18-
"formatting": "prettier src --check",
19-
"prettier:fix": "prettier src --write"
18+
"formatting": "prettier src examples __tests__ --check",
19+
"prettier:fix": "prettier src examples __tests__ --write"
2020
},
2121
"dependencies": {
2222
"@types/node": "^20.10.4"

src/skytable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function createSkytable(connection: Socket | TLSSocket) {
3535
const data = [query.length, '\n', dataframe];
3636
const requestData = ['S', data.join('').length, '\n', ...data];
3737
const buffer = Buffer.from(requestData.join(''), 'utf-8');
38-
38+
3939
const res = await connectionWrite(connection, buffer);
4040

4141
return formatResponse(res);

0 commit comments

Comments
 (0)