renew schema and tests for new dtabases
This commit is contained in:
@@ -95,6 +95,21 @@ test('route, POI, media and storage services cover successful and rejected lifec
|
||||
assert.equal(route.name, 'Äußerst schöne Strecke');
|
||||
assert.equal(route.pointCount, 2);
|
||||
assert.ok(fs.existsSync(routes.getRouteGpxFile(db, route.id).absolutePath));
|
||||
assert.equal(db.prepare("SELECT name FROM sqlite_master WHERE name='route_points'").get(), undefined);
|
||||
const routeColumns = db.prepare('PRAGMA table_info(routes)').all().map(column => column.name);
|
||||
for (const name of ['start_lat', 'center_lat', 'distance_m', 'elevation_gain_m', 'point_count']) {
|
||||
assert.equal(routeColumns.includes(name), false);
|
||||
}
|
||||
const gpxFilename = routes.getRouteGpxFile(db, route.id).absolutePath;
|
||||
const originalGpx = fs.readFileSync(gpxFilename, 'utf8');
|
||||
fs.writeFileSync(gpxFilename, GPX_APPEND);
|
||||
const fromFile = routes.getRoute(db, route.id);
|
||||
assert.equal(fromFile.pointCount, 1);
|
||||
assert.equal(fromFile.points[0].lat, 50.002);
|
||||
assert.equal(fromFile.start.lat, 50.002);
|
||||
assert.equal(fromFile.distanceM, 0);
|
||||
assert.equal(routes.listRoutes(db, {})[0].pointCount, 1);
|
||||
fs.writeFileSync(gpxFilename, originalGpx);
|
||||
|
||||
const duplicate = routes.createRoute(db, {
|
||||
name: 'Zweite Strecke',
|
||||
@@ -127,6 +142,17 @@ test('route, POI, media and storage services cover successful and rejected lifec
|
||||
expectHttpError(() => routes.appendRoute(db, 999999, uploadedFile('missing.gpx', GPX)), 404);
|
||||
const appended = routes.appendRoute(db, route.id, uploadedFile('append.gpx', GPX));
|
||||
assert.equal(appended.pointCount, 3);
|
||||
assert.equal(db.prepare('SELECT max_lat FROM routes WHERE id=?').get(route.id).max_lat, 50.002);
|
||||
|
||||
const indoor = routes.createRoute(db, { name: 'Drinnen' }, uploadedFile('indoor.gpx',
|
||||
'<gpx xmlns:wegwichtel="urn:wegwichtel:poi"><extensions><wegwichtel:gpsGap time="2026-10-03T10:00:00Z"/></extensions></gpx>'));
|
||||
const indoorStation = routes.createPoi(db, indoor.id, { title: 'Ohne GPS', lat: null, lon: null });
|
||||
assert.equal(routes.getRoute(db, indoor.id).pois[0].lat, null);
|
||||
routes.updatePoi(db, indoor.id, indoorStation.id, { lat: 50, lon: 10 });
|
||||
assert.equal(db.prepare('SELECT min_lat FROM routes WHERE id=?').get(indoor.id).min_lat, 50);
|
||||
routes.deletePoi(db, indoor.id, indoorStation.id);
|
||||
assert.equal(routes.getRoute(db, indoor.id).pointCount, 0);
|
||||
assert.equal(db.prepare('SELECT min_lat FROM routes WHERE id=?').get(indoor.id).min_lat, null);
|
||||
|
||||
expectHttpError(() => routes.createPoi(db, 999999, { lat: 1, lon: 2 }), 404);
|
||||
expectHttpError(() => routes.createPoi(db, route.id, { lat: 'x', lon: 2 }), 400);
|
||||
|
||||
Reference in New Issue
Block a user