azavea / tilegarden

Serverless raster and vector map tile generation using Mapnik and AWS Lambda
https://azavea.github.io/tilegarden/
Other
98 stars 7 forks source link

Feature/testing and error handling #51

Closed mattdelsordo closed 6 years ago

mattdelsordo commented 6 years ago

Overview

This PR adds testing infrastructure with Jest and implements several suites of tests. It also implements some code fixes in response to the results of those tests, as well as the ability for the tiler to handle errors by serving 256x256 .pngs containing the error message.

Demo

image

root@b0c5bda60a4e:/home/tiler# yarn test
yarn run v1.5.1
$ eslint src && yarn transpile && jest --coverage
$ yarn build-xml && babel src -d bin --copy-files --source-maps inline
$ babel-node src/util/build-xml.js src/config/map-config.mml bin/map-config.xml
src/api.js -> bin/api.js
src/tiler.js -> bin/tiler.js
src/util/build-xml.js -> bin/util/build-xml.js
src/util/fs-promise.js -> bin/util/fs-promise.js
src/util/layer-filter.js -> bin/util/layer-filter.js
src/util/message-tile.js -> bin/util/message-tile.js
 PASS  tests/layer-filter.test.js
 PASS  tests/api.test.js

 RUNS  tests/build-xml.test.js
 RUNS  tests/message-tile.test.js

Test Suites: 2 passed, 2 of 4 total
Tests:       15 passed, 15 total
Snapshots:   0 total
Time:        1s, estimated 2sTypeError: path must be a string or Buffer
    at Object.fs.readFile (fs.js:358:11)
    at /home/tiler/src/util/fs-promise.js:8:8
    at new Promise (<anonymous>)
 PASS  tests/build-xml.test.jsrc/util/fs-promise.js:7:45)
 PASS  tests/message-tile.test.js
-----------------|----------|----------|----------|----------|-------------------|
File             |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
-----------------|----------|----------|----------|----------|-------------------|
All files        |    91.89 |       75 |      100 |      100 |                   |
 layer-filter.js |       95 |     87.5 |      100 |      100 |                13 |
 message-tile.js |    88.24 |       50 |      100 |      100 |             12,19 |
-----------------|----------|----------|----------|----------|-------------------|

Test Suites: 4 passed, 4 total
Tests:       20 passed, 20 total
Snapshots:   0 total
Time:        1.843s, estimated 2s
Ran all test suites.
Done in 4.44s.

Testing Instructions

Resolves #14