Add tests for the ~ ltree operator (#2267)

This commit is contained in:
Laurence Isla
2022-04-26 22:48:15 +02:00
committed by GitHub
parent 115dae7484
commit a8477b7822
2 changed files with 31 additions and 0 deletions
+23
View File
@@ -20,6 +20,29 @@ spec = describe "extra search path" $ do
{"path":"Top.Science.Astronomy.Cosmology"}]|]
{ matchHeaders = [matchContentTypeJson] }
it "finds the ltree ~ operator on the public schema" $ do
request methodGet "/ltree_sample?path=match.*.Science" [] ""
`shouldRespondWith` [json|[
{"path": "Top.Science"}]|]
{ matchHeaders = [matchContentTypeJson] }
request methodGet "/ltree_sample?path=match.*.Astronomy.*" [] ""
`shouldRespondWith` [json|[
{"path": "Top.Science.Astronomy"},
{"path": "Top.Science.Astronomy.Astrophysics"},
{"path": "Top.Science.Astronomy.Cosmology"},
{"path": "Top.Collections.Pictures.Astronomy"},
{"path": "Top.Collections.Pictures.Astronomy.Stars"},
{"path": "Top.Collections.Pictures.Astronomy.Galaxies"},
{"path": "Top.Collections.Pictures.Astronomy.Astronauts"}]|]
{ matchHeaders = [matchContentTypeJson] }
request methodGet "/ltree_sample?path=match.*.Collections.*{1,2}" [] ""
`shouldRespondWith` [json|[
{"path": "Top.Collections.Pictures"},
{"path": "Top.Collections.Pictures.Astronomy"}]|]
{ matchHeaders = [matchContentTypeJson] }
it "finds the ltree nlevel function on the public schema, used through a computed column" $
request methodGet "/ltree_sample?select=number_of_labels&path=eq.Top.Science" [] ""
`shouldRespondWith` [json|[{"number_of_labels":2}]|]
+8
View File
@@ -543,6 +543,14 @@ INSERT INTO ltree_sample VALUES ('Top.Science');
INSERT INTO ltree_sample VALUES ('Top.Science.Astronomy');
INSERT INTO ltree_sample VALUES ('Top.Science.Astronomy.Astrophysics');
INSERT INTO ltree_sample VALUES ('Top.Science.Astronomy.Cosmology');
INSERT INTO ltree_sample VALUES ('Top.Hobbies');
INSERT INTO ltree_sample VALUES ('Top.Hobbies.Amateurs_Astronomy');
INSERT INTO ltree_sample VALUES ('Top.Collections');
INSERT INTO ltree_sample VALUES ('Top.Collections.Pictures');
INSERT INTO ltree_sample VALUES ('Top.Collections.Pictures.Astronomy');
INSERT INTO ltree_sample VALUES ('Top.Collections.Pictures.Astronomy.Stars');
INSERT INTO ltree_sample VALUES ('Top.Collections.Pictures.Astronomy.Galaxies');
INSERT INTO ltree_sample VALUES ('Top.Collections.Pictures.Astronomy.Astronauts');
TRUNCATE TABLE isn_sample CASCADE;
INSERT INTO isn_sample VALUES ('978-0-393-04002-9', 'Mathematics: From the Birth of Numbers');