-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: basic Redis grammar, parseRedisQueryWithoutCursor function, tests #207
Changes from 1 commit
3fd0a09
1626eee
57e58cc
7794dc7
985ae5e
e468280
f5b9d76
fc32412
01cf6e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {parseRedisQueryWithoutCursor} from '../../index'; | ||
|
||
test('should not report errors on DECR command', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('DECR test'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); | ||
|
||
test('should not report errors on multiple DECR commands', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('DECR test\nDECR 123'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); | ||
|
||
test('should report errors on DECR command without arguments', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('DECR'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(1); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {parseRedisQueryWithoutCursor} from '../../index'; | ||
|
||
test('should not report errors on GET command', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('GET test'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); | ||
|
||
test('should not report errors on multiple GET commands', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('GET test\nGET 123'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); | ||
|
||
test('should report errors on GET command without arguments', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('GET'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(1); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import {parseRedisQueryWithoutCursor} from '../../index'; | ||
|
||
test('should not report errors on string identifier', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('GET test'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); | ||
|
||
test('should not report errors on number identifier', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('GET 123'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); | ||
|
||
test('should not report errors on identifier with special symbols', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('GET test123;:,.$#!@%-=+-~()[]{}'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); | ||
|
||
test('should report errors on identifier with double quote', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('GET test"'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(1); | ||
}); | ||
|
||
test('should report errors on identifier with single quote', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor("GET test'"); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(1); | ||
}); | ||
|
||
test('should report errors on identifier with space', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('GET test test'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(1); | ||
}); | ||
|
||
test('should not report errors on double quoted identifier', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('GET "test123;:,.$#!@%-=+-~()[]{}"'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); | ||
|
||
test('should not report errors on single quoted identifier', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor("GET 'test123;:,.$#!@%-=+-~()[]{}'"); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {parseRedisQueryWithoutCursor} from '../../index'; | ||
|
||
test('should not report errors on INCR command', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('INCR test'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); | ||
|
||
test('should not report errors on multiple INCR commands', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('INCR test\nINCR 123'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We split queries by newline? Maybe it's better to force There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can't use semicolon, because it is valid to use in key/value name, e.g. |
||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); | ||
|
||
test('should report errors on INCR command without arguments', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('INCR'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(1); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import {parseRedisQueryWithoutCursor} from '../../index'; | ||
|
||
test('should not report errors on SET command', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('SET test test'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); | ||
|
||
test('should not report errors on multiple SET commands', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('SET test test\nSET 123 123'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); | ||
|
||
test('should report errors on SET command without arguments', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('SET'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(1); | ||
}); | ||
|
||
test('should not report errors on SET command with NX argument', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('SET test test NX'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); | ||
|
||
test('should not report errors on SET command with XX argument', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('SET test test XX'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); | ||
|
||
test('should not report errors on SET command with GET argument', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('SET test test GET'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); | ||
|
||
test('should not report errors on SET command with EX argument', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('SET test test EX 123'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); | ||
|
||
test('should not report errors on SET command with PX argument', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('SET test test PX 123'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); | ||
|
||
test('should not report errors on SET command with EXAT argument', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('SET test test EXAT 123'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); | ||
|
||
test('should not report errors on SET command with PXAT argument', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('SET test test PXAT 123'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); | ||
|
||
test('should not report errors on SET command with KEEPTTL argument', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('SET test test KEEPTTL'); | ||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); | ||
|
||
test('should not report errors on SET command with all argument', () => { | ||
const autocompleteResult = parseRedisQueryWithoutCursor('SET test test XX GET PXAT 123'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's part of official syntax of course - https://redis.io/docs/latest/commands/set/ |
||
|
||
expect(autocompleteResult.errors).toHaveLength(0); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to have a separete multiple commands test. Because in the end we want to test
commands
rule 3fd0a09#diff-b96534631ee82ffc85910f193fcacb74b496e3324eef92e1d7121103f2321683R16