1 | var testConfig = {
|
2 | 'PostgresURL': 'postgres://localhost/osm-comments-api-test'
|
3 | };
|
4 | require('../lib/config')(testConfig);
|
5 | var testList = require('./fixtures/notes/test_list.json');
|
6 | var fs = require('fs');
|
7 | var path = require('path');
|
8 | var notes = require('../notes');
|
9 | var basePath = path.join(__dirname, 'fixtures', 'notes');
|
10 |
|
11 | testList.forEach(function(t) {
|
12 | var fixturePath = path.join(basePath, t.fixture);
|
13 | console.log('reading file ' + fixturePath);
|
14 | var fixture = JSON.parse(fs.readFileSync(fixturePath));
|
15 | var fn;
|
16 | var param;
|
17 | if (fixture.params) {
|
18 | fn = notes.search;
|
19 | param = fixture.params;
|
20 | } else {
|
21 | fn = notes.get;
|
22 | param = fixture.id;
|
23 | }
|
24 | fn(param, function(err, geojson) {
|
25 | console.log('geojson returned', geojson);
|
26 | fixture.geojson = geojson;
|
27 | fs.writeFileSync(fixturePath, JSON.stringify(fixture, null, 2));
|
28 | console.log('written file ' + fixturePath);
|
29 | });
|
30 | });
|