2022-08-13 22:08:34 +03:00
|
|
|
/+ parse, *test
|
|
|
|
::
|
|
|
|
:: we frequently break the rules of unit and regression tests here
|
|
|
|
:: by testing more than one thing per result, otherwise there would
|
|
|
|
:: just be too many tests
|
|
|
|
::
|
|
|
|
:: each arm tests one urql command
|
|
|
|
::
|
|
|
|
:: common things to test
|
|
|
|
:: 1) basic command works producing AST object
|
|
|
|
:: 2) multiple ASTs
|
|
|
|
:: 3) all keywords are case ambivalent
|
|
|
|
:: 4) all names follow rules for faces
|
|
|
|
:: 5) all qualifier combinations work
|
|
|
|
::
|
|
|
|
:: -test /=urql=/tests/lib/parse/hoon ~
|
2022-08-06 17:06:18 +03:00
|
|
|
|%
|
2022-08-13 22:08:34 +03:00
|
|
|
:: current database must be proper face
|
|
|
|
++ test-current-database
|
|
|
|
%- expect-fail
|
2022-08-21 03:29:26 +03:00
|
|
|
|. (parse:parse(current-database 'oTher-db') "cReate\0d\09 namespace my-namespace")
|
|
|
|
::
|
|
|
|
:: create database
|
2022-08-13 22:08:34 +03:00
|
|
|
::
|
2022-08-14 00:20:30 +03:00
|
|
|
:: tests 1, 3, and extra whitespace characters
|
|
|
|
++ test-create-database-1
|
|
|
|
%+ expect-eq
|
|
|
|
!> ~[[%create-database name='my-database']]
|
2022-08-21 03:29:26 +03:00
|
|
|
!> (parse:parse(current-database 'dummy') "cReate datAbase \0a my-database ")
|
2022-08-14 00:20:30 +03:00
|
|
|
::
|
|
|
|
:: subsequent commands ignored
|
|
|
|
++ test-create-database-2
|
|
|
|
%+ expect-eq
|
|
|
|
!> ~[[%create-database name='my-database']]
|
2022-08-21 03:29:26 +03:00
|
|
|
!> (parse:parse(current-database 'dummy') "cReate datAbase \0a my-database; cReate namesPace my-db.another-namespace")
|
2022-08-14 00:20:30 +03:00
|
|
|
::
|
2022-08-21 03:29:26 +03:00
|
|
|
:: fail when database name is not a term
|
2022-08-14 00:20:30 +03:00
|
|
|
++ test-create-database-3
|
|
|
|
%- expect-fail
|
2022-08-21 03:29:26 +03:00
|
|
|
|. (parse:parse(current-database 'dummy') "cReate datAbase My-database")
|
2022-08-14 00:20:30 +03:00
|
|
|
::
|
|
|
|
:: fail when commands are prior to create database
|
|
|
|
++ test-create-database-4
|
|
|
|
%- expect-fail
|
2022-08-21 03:29:26 +03:00
|
|
|
|. (parse:parse(current-database 'dummy') "create namespace my-namespace ; cReate datAbase my-database")
|
|
|
|
::
|
|
|
|
:: create namespace
|
2022-08-14 00:20:30 +03:00
|
|
|
::
|
2022-08-13 22:08:34 +03:00
|
|
|
:: tests 1, 2, 3, 5, and extra whitespace characters
|
|
|
|
++ test-create-namespace-1
|
|
|
|
=/ expected1 [%create-namespace database-name='other-db' name='my-namespace']
|
|
|
|
=/ expected2 [%create-namespace database-name='my-db' name='another-namespace']
|
|
|
|
%+ expect-eq
|
|
|
|
!> ~[expected1 expected2]
|
2022-08-21 03:29:26 +03:00
|
|
|
!> (parse:parse(current-database 'other-db') "cReate\0d\09 namespace my-namespace ; cReate namesPace my-db.another-namespace")
|
2022-08-13 22:08:34 +03:00
|
|
|
::
|
|
|
|
:: leading and trailing whitespace characters, end delimiter not required on single
|
|
|
|
++ test-create-namespace-2
|
|
|
|
%+ expect-eq
|
|
|
|
!> ~[[%create-namespace database-name='other-db' name='my-namespace']]
|
2022-08-21 03:29:26 +03:00
|
|
|
!> (parse:parse(current-database 'other-db') " \09cReate\0d\09 namespace my-namespace ")
|
2022-08-13 22:08:34 +03:00
|
|
|
::
|
2022-08-21 03:29:26 +03:00
|
|
|
:: fail when database qualifier is not a term
|
2022-08-13 22:08:34 +03:00
|
|
|
++ test-create-namespace-3
|
|
|
|
%- expect-fail
|
2022-08-21 03:29:26 +03:00
|
|
|
|. (parse:parse(current-database 'other-db') "cReate namesPace Bad-face.another-namespace")
|
2022-08-13 22:08:34 +03:00
|
|
|
::
|
2022-08-21 03:29:26 +03:00
|
|
|
:: fail when namespace is not a term
|
2022-08-13 22:08:34 +03:00
|
|
|
++ test-create-namespace-4
|
|
|
|
%- expect-fail
|
2022-08-21 03:29:26 +03:00
|
|
|
|. (parse:parse(current-database 'other-db') "cReate namesPace my-db.Bad-face")
|
|
|
|
::
|
2022-08-22 01:01:22 +03:00
|
|
|
:: drop database
|
|
|
|
::
|
|
|
|
:: tests 1, 2, 3, 5, and extra whitespace characters, force db.name, name
|
|
|
|
++ test-drop-database-1
|
|
|
|
=/ expected1 [%drop-database name='name' force=%.n]
|
|
|
|
=/ expected2 [%drop-database name='name' force=%.y]
|
|
|
|
%+ expect-eq
|
|
|
|
!> ~[expected1 expected2]
|
|
|
|
!> (parse:parse(current-database 'other-db') "droP Database name;droP \0d\09 DataBase FORce \0a name")
|
|
|
|
::
|
|
|
|
:: leading and trailing whitespace characters, end delimiter not required on single, force name
|
|
|
|
++ test-drop-database-2
|
|
|
|
%+ expect-eq
|
|
|
|
!> ~[[%drop-database name='name' force=%.y]]
|
|
|
|
!> (parse:parse(current-database 'other-db') " \09drOp\0d\09 dAtabaSe\0a force name ")
|
|
|
|
::
|
|
|
|
:: fail when database is not a term
|
|
|
|
++ test-drop-database-3
|
|
|
|
%- expect-fail
|
|
|
|
|. (parse:parse(current-database 'other-db') "DROP DATABASE nAme")
|
|
|
|
::
|
2022-08-21 22:12:55 +03:00
|
|
|
:: drop namespace
|
|
|
|
::
|
|
|
|
:: tests 1, 2, 3, 5, and extra whitespace characters, force db.name, name
|
|
|
|
++ test-drop-namespace-1
|
|
|
|
=/ expected1 [%drop-namespace database-name='db' name='name' force=%.n]
|
|
|
|
=/ expected2 [%drop-namespace database-name='other-db' name='name' force=%.y]
|
|
|
|
%+ expect-eq
|
|
|
|
!> ~[expected1 expected2]
|
|
|
|
!> (parse:parse(current-database 'other-db') "droP Namespace db.name;droP \0d\09 Namespace FORce \0a name")
|
|
|
|
::
|
|
|
|
:: leading and trailing whitespace characters, end delimiter not required on single, force name
|
|
|
|
++ test-drop-namespace-2
|
|
|
|
%+ expect-eq
|
|
|
|
!> ~[[%drop-namespace database-name='other-db' name='name' force=%.y]]
|
2022-08-22 00:09:24 +03:00
|
|
|
!> (parse:parse(current-database 'other-db') " \09drOp\0d\09 naMespace\0a force name ")
|
2022-08-21 22:12:55 +03:00
|
|
|
::
|
|
|
|
:: db.name
|
|
|
|
++ test-drop-namespace-3
|
|
|
|
%+ expect-eq
|
|
|
|
!> ~[[%drop-namespace database-name='db' name='name' force=%.n]]
|
|
|
|
!> (parse:parse(current-database 'other-db') "drop namespace db.name")
|
|
|
|
::
|
|
|
|
:: fail when database qualifier is not a term
|
|
|
|
++ test-drop-namespace-4
|
|
|
|
%- expect-fail
|
|
|
|
|. (parse:parse(current-database 'other-db') "DROP NAMESPACE Db.name")
|
|
|
|
::
|
|
|
|
:: fail when namespace is not a term
|
|
|
|
++ test-drop-namespace-5
|
|
|
|
%- expect-fail
|
|
|
|
|. (parse:parse(current-database 'other-db') "DROP NAMESPACE nAme")
|
|
|
|
::
|
2022-08-21 03:29:26 +03:00
|
|
|
:: drop table
|
2022-08-16 22:18:14 +03:00
|
|
|
::
|
|
|
|
:: tests 1, 2, 3, 5, and extra whitespace characters
|
2022-08-17 19:35:12 +03:00
|
|
|
++ test-drop-table-1
|
2022-08-22 04:03:52 +03:00
|
|
|
=/ expected1 [%drop-table table=[%qualified-object ship=~ database='db' namespace='ns' name='name'] force=%.y]
|
|
|
|
=/ expected2 [%drop-table table=[%qualified-object ship=~ database='db' namespace='ns' name='name'] force=%.n]
|
2022-08-17 19:35:12 +03:00
|
|
|
%+ expect-eq
|
|
|
|
!> ~[expected1 expected2]
|
2022-08-21 03:29:26 +03:00
|
|
|
!> (parse:parse(current-database 'other-db') "droP table FORce db.ns.name;droP table \0a db.ns.name")
|
2022-08-17 19:35:12 +03:00
|
|
|
::
|
2022-08-21 03:29:26 +03:00
|
|
|
:: leading and trailing whitespace characters, end delimiter not required on single, force db..name
|
2022-08-17 19:35:12 +03:00
|
|
|
++ test-drop-table-2
|
|
|
|
%+ expect-eq
|
2022-08-22 04:03:52 +03:00
|
|
|
!> ~[[%drop-table table=[%qualified-object ship=~ database='db' namespace='dbo' name='name'] force=%.y]]
|
2022-08-21 03:29:26 +03:00
|
|
|
!> (parse:parse(current-database 'other-db') " \09drop\0d\09 table\0aforce db..name ")
|
|
|
|
::
|
|
|
|
:: db..name
|
2022-08-17 19:35:12 +03:00
|
|
|
++ test-drop-table-3
|
|
|
|
%+ expect-eq
|
2022-08-22 04:03:52 +03:00
|
|
|
!> ~[[%drop-table table=[%qualified-object ship=~ database='db' namespace='dbo' name='name'] force=%.n]]
|
2022-08-21 03:29:26 +03:00
|
|
|
!> (parse:parse(current-database 'other-db') "drop table db..name")
|
|
|
|
::
|
|
|
|
:: force ns.name
|
2022-08-17 19:35:12 +03:00
|
|
|
++ test-drop-table-4
|
|
|
|
%+ expect-eq
|
2022-08-22 04:03:52 +03:00
|
|
|
!> ~[[%drop-table table=[%qualified-object ship=~ database='other-db' namespace='ns' name='name'] force=%.y]]
|
2022-08-21 03:29:26 +03:00
|
|
|
!> (parse:parse(current-database 'other-db') "drop table force ns.name")
|
|
|
|
::
|
|
|
|
:: ns.name
|
2022-08-17 19:35:12 +03:00
|
|
|
++ test-drop-table-5
|
|
|
|
%+ expect-eq
|
2022-08-22 04:03:52 +03:00
|
|
|
!> ~[[%drop-table table=[%qualified-object ship=~ database='other-db' namespace='ns' name='name'] force=%.n]]
|
2022-08-21 03:29:26 +03:00
|
|
|
!> (parse:parse(current-database 'other-db') "drop table ns.name")
|
|
|
|
::
|
|
|
|
:: force name
|
2022-08-17 19:35:12 +03:00
|
|
|
++ test-drop-table-6
|
|
|
|
%+ expect-eq
|
2022-08-22 04:03:52 +03:00
|
|
|
!> ~[[%drop-table table=[%qualified-object ship=~ database='other-db' namespace='dbo' name='name'] force=%.y]]
|
2022-08-21 03:29:26 +03:00
|
|
|
!> (parse:parse(current-database 'other-db') "DROP table FORCE name")
|
|
|
|
:: name
|
|
|
|
++ test-drop-table-7
|
2022-08-17 19:35:12 +03:00
|
|
|
%+ expect-eq
|
2022-08-22 04:03:52 +03:00
|
|
|
!> ~[[%drop-table table=[%qualified-object ship=~ database='other-db' namespace='dbo' name='name'] force=%.n]]
|
2022-08-21 03:29:26 +03:00
|
|
|
!> (parse:parse(current-database 'other-db') "DROP table name")
|
2022-08-17 19:35:12 +03:00
|
|
|
::
|
2022-08-21 03:29:26 +03:00
|
|
|
:: fail when database qualifier is not a term
|
|
|
|
++ test-drop-table-8
|
2022-08-17 19:35:12 +03:00
|
|
|
%- expect-fail
|
2022-08-21 03:29:26 +03:00
|
|
|
|. (parse:parse(current-database 'other-db') "DROP table Db.ns.name")
|
2022-08-17 19:35:12 +03:00
|
|
|
|
2022-08-21 03:29:26 +03:00
|
|
|
:: fail when namespace qualifier is not a term
|
|
|
|
++ test-drop-table-9
|
2022-08-17 19:35:12 +03:00
|
|
|
%- expect-fail
|
2022-08-21 03:29:26 +03:00
|
|
|
|. (parse:parse(current-database 'other-db') "DROP table db.nS.name")
|
2022-08-17 19:35:12 +03:00
|
|
|
::
|
2022-08-21 03:29:26 +03:00
|
|
|
:: fail when table name is not a term
|
|
|
|
++ test-drop-table-10
|
2022-08-17 19:35:12 +03:00
|
|
|
%- expect-fail
|
2022-08-21 03:29:26 +03:00
|
|
|
|. (parse:parse(current-database 'other-db') "DROP table db.ns.nAme")
|
|
|
|
::
|
|
|
|
:: drop view
|
2022-08-17 19:35:12 +03:00
|
|
|
::
|
|
|
|
:: tests 1, 2, 3, 5, and extra whitespace characters
|
2022-08-16 22:18:14 +03:00
|
|
|
++ test-drop-view-1
|
2022-08-22 04:03:52 +03:00
|
|
|
=/ expected1 [%drop-view view=[%qualified-object ship=~ database='db' namespace='ns' name='name'] force=%.y]
|
|
|
|
=/ expected2 [%drop-view view=[%qualified-object ship=~ database='db' namespace='ns' name='name'] force=%.n]
|
2022-08-16 22:18:14 +03:00
|
|
|
%+ expect-eq
|
|
|
|
!> ~[expected1 expected2]
|
2022-08-21 03:29:26 +03:00
|
|
|
!> (parse:parse(current-database 'other-db') "droP View FORce db.ns.name;droP View \0a db.ns.name")
|
2022-08-16 22:18:14 +03:00
|
|
|
::
|
2022-08-21 03:29:26 +03:00
|
|
|
:: leading and trailing whitespace characters, end delimiter not required on single, force db..name
|
2022-08-16 22:18:14 +03:00
|
|
|
++ test-drop-view-2
|
|
|
|
%+ expect-eq
|
2022-08-22 04:03:52 +03:00
|
|
|
!> ~[[%drop-view view=[%qualified-object ship=~ database='db' namespace='dbo' name='name'] force=%.y]]
|
2022-08-21 03:29:26 +03:00
|
|
|
!> (parse:parse(current-database 'other-db') " \09drop\0d\09 vIew\0aforce db..name ")
|
|
|
|
::
|
|
|
|
:: db..name
|
2022-08-16 22:18:14 +03:00
|
|
|
++ test-drop-view-3
|
|
|
|
%+ expect-eq
|
2022-08-22 04:03:52 +03:00
|
|
|
!> ~[[%drop-view view=[%qualified-object ship=~ database='db' namespace='dbo' name='name'] force=%.n]]
|
2022-08-21 03:29:26 +03:00
|
|
|
!> (parse:parse(current-database 'other-db') "drop view db..name")
|
|
|
|
::
|
|
|
|
:: force ns.name
|
2022-08-16 22:18:14 +03:00
|
|
|
++ test-drop-view-4
|
|
|
|
%+ expect-eq
|
2022-08-22 04:03:52 +03:00
|
|
|
!> ~[[%drop-view view=[%qualified-object ship=~ database='other-db' namespace='ns' name='name'] force=%.y]]
|
2022-08-21 03:29:26 +03:00
|
|
|
!> (parse:parse(current-database 'other-db') "drop view force ns.name")
|
|
|
|
::
|
|
|
|
:: ns.name
|
2022-08-16 22:18:14 +03:00
|
|
|
++ test-drop-view-5
|
|
|
|
%+ expect-eq
|
2022-08-22 04:03:52 +03:00
|
|
|
!> ~[[%drop-view view=[%qualified-object ship=~ database='other-db' namespace='ns' name='name'] force=%.n]]
|
2022-08-21 03:29:26 +03:00
|
|
|
!> (parse:parse(current-database 'other-db') "drop view ns.name")
|
|
|
|
::
|
|
|
|
:: force name
|
2022-08-16 22:18:14 +03:00
|
|
|
++ test-drop-view-6
|
|
|
|
%+ expect-eq
|
2022-08-22 04:03:52 +03:00
|
|
|
!> ~[[%drop-view view=[%qualified-object ship=~ database='other-db' namespace='dbo' name='name'] force=%.y]]
|
2022-08-21 03:29:26 +03:00
|
|
|
!> (parse:parse(current-database 'other-db') "DROP VIEW FORCE name")
|
|
|
|
::
|
|
|
|
:: name
|
2022-08-16 22:18:14 +03:00
|
|
|
++ test-drop-view-7
|
|
|
|
%+ expect-eq
|
2022-08-22 04:03:52 +03:00
|
|
|
!> ~[[%drop-view view=[%qualified-object ship=~ database='other-db' namespace='dbo' name='name'] force=%.n]]
|
2022-08-21 03:29:26 +03:00
|
|
|
!> (parse:parse(current-database 'other-db') "DROP VIEW name")
|
|
|
|
::
|
|
|
|
:: fail when database qualifier is not a term
|
2022-08-16 22:18:14 +03:00
|
|
|
++ test-drop-view-8
|
2022-08-21 03:29:26 +03:00
|
|
|
%- expect-fail
|
|
|
|
|. (parse:parse(current-database 'other-db') "DROP VIEW Db.ns.name")
|
|
|
|
:: fail when namespace qualifier is not a term
|
2022-08-16 22:18:14 +03:00
|
|
|
++ test-drop-view-9
|
2022-08-21 03:29:26 +03:00
|
|
|
%- expect-fail
|
|
|
|
|. (parse:parse(current-database 'other-db') "DROP VIEW db.nS.name")
|
2022-08-16 22:18:14 +03:00
|
|
|
::
|
2022-08-21 03:29:26 +03:00
|
|
|
:: fail when view name is not a term
|
2022-08-16 22:18:14 +03:00
|
|
|
++ test-drop-view-10
|
|
|
|
%- expect-fail
|
2022-08-21 03:29:26 +03:00
|
|
|
|. (parse:parse(current-database 'other-db') "DROP VIEW db.ns.nAme")
|
|
|
|
::
|
|
|
|
:: truncate table
|
|
|
|
::
|
|
|
|
:: tests 1, 2, 3, 5, and extra whitespace characters
|
|
|
|
++ test-truncate-table-1
|
|
|
|
=/ expected1 [%truncate-table table=[%qualified-object ship=[~ ~zod] database='db' namespace='ns' name='name']]
|
|
|
|
=/ expected2 [%truncate-table table=[%qualified-object ship=[~ ~sampel-palnet] database='db' namespace='dbo' name='name']]
|
|
|
|
%+ expect-eq
|
|
|
|
!> ~[expected1 expected2]
|
|
|
|
!> (parse:parse(current-database 'dummy') " \0atrUncate TAble\0d ~zod.db.ns.name\0a; truncate table ~sampel-palnet.db..name")
|
|
|
|
::
|
|
|
|
:: leading and trailing whitespace characters, end delimiter not required on single, db.ns.name
|
|
|
|
++ test-truncate-table-2
|
|
|
|
%+ expect-eq
|
|
|
|
!> ~[[%truncate-table table=[%qualified-object ship=~ database='db' namespace='ns' name='name']]]
|
|
|
|
!> (parse:parse(current-database 'dummy') " \09truncate\0d\09 TaBle\0a db.ns.name ")
|
|
|
|
::
|
|
|
|
:: db..name
|
|
|
|
++ test-truncate-table-3
|
|
|
|
%+ expect-eq
|
|
|
|
!> ~[[%truncate-table table=[%qualified-object ship=~ database='db' namespace='dbo' name='name']]]
|
|
|
|
!> (parse:parse(current-database 'dummy') "truncate table db..name")
|
|
|
|
::
|
|
|
|
:: ns.name
|
|
|
|
++ test-truncate-table-4
|
|
|
|
%+ expect-eq
|
|
|
|
!> ~[[%truncate-table table=[%qualified-object ship=~ database='dummy' namespace='ns' name='name']]]
|
|
|
|
!> (parse:parse(current-database 'dummy') "truncate table ns.name")
|
|
|
|
::
|
|
|
|
:: name
|
|
|
|
++ test-truncate-table-5
|
|
|
|
%+ expect-eq
|
|
|
|
!> ~[[%truncate-table table=[%qualified-object ship=~ database='dummy' namespace='dbo' name='name']]]
|
|
|
|
!> (parse:parse(current-database 'dummy') "truncate table name")
|
|
|
|
::
|
|
|
|
:: fail when database qualifier is not a term
|
|
|
|
++ test-truncate-table-6
|
|
|
|
%- expect-fail
|
|
|
|
|. (parse:parse(current-database 'dummy') "truncate table Db.ns.name")
|
2022-08-13 22:08:34 +03:00
|
|
|
|
2022-08-21 03:29:26 +03:00
|
|
|
:: fail when namespace qualifier is not a term
|
|
|
|
++ test-truncate-table-7
|
|
|
|
%- expect-fail
|
|
|
|
|. (parse:parse(current-database 'dummy') "truncate table db.nS.name")
|
|
|
|
::
|
|
|
|
:: fail when view name is not a term
|
|
|
|
++ test-truncate-table-8
|
|
|
|
%- expect-fail
|
|
|
|
|. (parse:parse(current-database 'dummy') "truncate table db.ns.nAme")
|
|
|
|
::
|
|
|
|
:: fail when view name is not a term
|
|
|
|
++ test-truncate-table-9
|
2022-08-16 22:18:14 +03:00
|
|
|
%- expect-fail
|
2022-08-21 03:29:26 +03:00
|
|
|
|. (parse:parse(current-database 'dummy') "truncate table db.ns.nAme")
|
2022-08-16 22:18:14 +03:00
|
|
|
::
|
2022-08-21 03:29:26 +03:00
|
|
|
:: fail when ship is invalid
|
|
|
|
++ test-truncate-table-10
|
2022-08-16 22:18:14 +03:00
|
|
|
%- expect-fail
|
2022-08-21 03:29:26 +03:00
|
|
|
|. (parse:parse(current-database 'dummy') "truncate table ~shitty-shippp db.ns.nAme")
|
2022-08-13 22:08:34 +03:00
|
|
|
--
|