UNPKG

964 BJavaScriptView Raw
1var testConfig = {
2 'PostgresURL': 'postgres://localhost/osm-comments-api-test'
3};
4require('../lib/config')(testConfig);
5var testList = require('./fixtures/notes/test_list.json');
6var fs = require('fs');
7var path = require('path');
8var notes = require('../notes');
9var basePath = path.join(__dirname, 'fixtures', 'notes');
10
11testList.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});