[Tile-serving] [openstreetmap/osm2pgsql] Include tests for sample configuration file (#1130)

mmd notifications at github.com
Sun May 24 19:52:53 UTC 2020


You could use some mock object for the osm2pgsql functionality provided by osm2pgsql:

(file osm2pgsql-mock-lua)

```
local osm2pgsql = {}

local inspect = require('inspect')

function osm2pgsql.define_table(o)

   local def_table = {}
   function def_table.add_row(x, y)
      print(inspect(y))
-- (store data somewhere for later retrieval in unit test)
   end

   return def_table
end

return osm2pgsql
```

... and use this mock object along with your original openstreetmap-carto.lua file to run some tests.

test.lua

```
osm2pgsql = require 'osm2pgsql-mock'
require 'openstreetmap-carto'


x = {}
x.tags = {}
x.tags["highway"] = "bus_stop"
x.tags["layer"] = "1"


-- simulate callback function call by osm2pgsql
osm2pgsql.process_node(x)

-- todo: check results by calling another mock function in osm2pgsql

```

Execute test.lua:

```
lua test.lua 
{
  highway = "bus_stop",
  layer = "1",
  tags = {
    layer = "1"
  }
}
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/issues/1130#issuecomment-633286967
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20200524/8f5251fe/attachment.htm>


More information about the Tile-serving mailing list