Skip to content

Commit fd5889b

Browse files
authored
add testGetWithBracketNotation (RedisJSON#416)
1 parent 5cf6b36 commit fd5889b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/pytest/test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,15 @@ def testSetWithBracketNotation(env):
182182
r.assertIsNone(r.execute_command('JSON.SET', 'x', '.["f3"].f2', '1')) # Fail trying to set f2 when f3 doesn't exist
183183
r.assertEqual(json.loads(r.execute_command('JSON.GET', 'x')), {'f1': {'f2': [0, {'f.]$.f': 1}, 0]}}) # Make sure it worked
184184

185+
def testGetWithBracketNotation(env):
186+
r = env
187+
188+
r.assertOk(r.execute_command('JSON.SET', 'x', '.', '[1,2,3]'))
189+
r.assertEqual(json.loads(r.execute_command('JSON.GET', 'x', '.[1]')), 2) # dot notation - single value
190+
r.assertEqual(json.loads(r.execute_command('JSON.GET', 'x', '[1]')), 2) # implicit dot notation - single value
191+
r.assertEqual(json.loads(r.execute_command('JSON.GET', 'x', '$.[1]')), [2]) # dollar notation - array
192+
r.assertEqual(json.loads(r.execute_command('JSON.GET', 'x', '$[1]')), [2]) # dollar notation - array
193+
185194
def testSetWithPathErrors(env):
186195
r = env
187196

0 commit comments

Comments
 (0)