Now creating a complete database initialisation script that runs.

This commit is contained in:
Simon Brooke 2019-11-16 13:15:27 +00:00
parent c2d006ac3b
commit 8f24c314a1
2 changed files with 44 additions and 27 deletions

View file

@ -421,4 +421,17 @@
(let [expected "------------------------------------------------------------------------\n--\tTest doc \n--\t\n--\tAll dwellings within addresses in the system; a\n--\t dwelling is a house, flat or appartment in which electors live.\n--\t Every address should have at least one dwelling; essentially,\n--\t an address maps onto a street door and dwellings map onto\n--\t what's behind that door. So a tenement or a block of flats\n--\t would be one address with many dwellings. \n------------------------------------------------------------------------\nCREATE TABLE dwellings\n(\n\t id SERIAL NOT NULL PRIMARY KEY,\n\t address_id INTEGER NOT NULL,\n\t sub_address VARCHAR(32)\n);\nGRANT SELECT ON dwellings TO admin,\n\tanalysts,\n\tcanvassers,\n\tissueeditors,\n\tissueexperts,\n\tteamorganisers ;\nGRANT INSERT ON dwellings TO admin ;\nGRANT UPDATE ON dwellings TO admin ;\nGRANT DELETE ON dwellings TO admin ;"
actual (emit-table dwelling-entity application "Test doc")]
(is (= actual expected))))
(testing "Convenience entity field - is an entity field, should emit"
(let [property (child-with-tag address-entity :property #(= (-> % :attrs :name) "district_id"))
expected "districts.name AS district_id_expanded"
actual (emit-convenience-entity-field property address-entity application)]
(is (= actual expected))))
(testing "Convenience entity field - is not an entity field, should not emit"
(let [farside dwelling-entity
property (child-with-tag address-entity :property #(= (-> % :attrs :name) "dwellings"))
expected nil
actual (emit-convenience-entity-field property address-entity application)]
(is (= actual expected))))
))