MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / test_lbugrc

Function test_lbugrc

tools/shell/test/test_shell_basics.py:269–310  ·  view source on GitHub ↗
(temp_db)

Source from the content-addressed store, hash-verified

267
268
269def test_lbugrc(temp_db) -> None:
270 deleteIfExists(".lbugrc")
271 # confirm that nothing is read on startup
272 test = ShellTest().add_argument(temp_db)
273 result = test.run()
274 result.check_not_stdout("-- Processing: .lbugrc")
275
276 # create a .lbugrc file
277 with open(".lbugrc", "w") as f:
278 f.write("CREATE NODE TABLE a(i STRING, PRIMARY KEY(i));\n")
279 f.write(":max_rows 1\n")
280
281 # confirm that the file is read on startup
282 test = ShellTest().add_argument(temp_db).statement("CALL show_tables() RETURN *;")
283 result = test.run()
284 deleteIfExists(".lbugrc")
285 result.check_stdout("-- Processing: .lbugrc")
286 result.check_stdout("maxRows set as 1")
287 result.check_stdout("a")
288
289 # create a .lbugrc file with errors
290 with open(".lbugrc", "w") as f:
291 f.write('RETURN "databases rule" S a; RETURN s;\n')
292 f.write(":max_rows\n")
293 f.write(":mode table\n")
294 f.write("CREATE NODE TABLE b(i STRING, PRIMARY KEY(i));\n")
295
296 # confirm that the file is read on startup
297 test = ShellTest().add_argument(temp_db).statement("CALL show_tables() RETURN *;")
298 result = test.run()
299 deleteIfExists(".lbugrc")
300 result.check_stdout("-- Processing: .lbugrc")
301 result.check_stdout(
302 [
303 "Error: Parser exception: Invalid input < S>: expected rule iC_Statements (line: 1, offset: 24)",
304 '"RETURN "databases rule" S a; RETURN s;"',
305 " ^",
306 ],
307 )
308 result.check_stdout("Cannot parse '' as number of rows. Expect integer.")
309 result.check_stdout("mode set as table")
310 result.check_stdout("b")
311
312
313def test_comments(temp_db) -> None:

Callers

nothing calls this directly

Calls 8

deleteIfExistsFunction · 0.90
ShellTestClass · 0.90
add_argumentMethod · 0.80
check_not_stdoutMethod · 0.80
statementMethod · 0.80
check_stdoutMethod · 0.80
runMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected