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

mmd notifications at github.com
Sun May 24 20:24:40 UTC 2020


Maybe we could enhance the test framework a bit to provide some very basic mock object for the osm2pgsql functionality provided by osm2pgsql. I believe this isn't supported by tests.lua as of now.

(file osm2pgsql-mock.lua)

```
local osm2pgsql = {}

local inspect = require('inspect')

result = {}

function osm2pgsql.define_table(o)

   local mock_table = {}

   mock_table.name = o.name
   mock_table.ids = o.ids
   mock_table.columns = o.columns

   function mock_table.add_row(x, y)
--      print(inspect(x))
--      print(inspect(y))
      result = y
         
   end

   return mock_table
end


function osm2pgsql.get_mock_result()
  return result
end

return osm2pgsql
```

File test.lua:

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


print("Running tests...")

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

osm2pgsql.process_node(x)

r = osm2pgsql.get_mock_result()

assert(r["highway"] == 'bus_stop')

print("Done...")
```

Executing test from command line:

```
lua test.lua 
Running tests...
Done...
```



-- 
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-633292987
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20200524/dc82267f/attachment.htm>


More information about the Tile-serving mailing list