include('ringo/unittest');
include('./testconsts');
var fs = require('fs-base');
var {getRingoHome} = require('ringo/engine');
var {Store} = require('ringo/storage/filestore');
var store = new Store('db');
var person, Person = store.defineClass('Person');

exports.testPersistCreation = function () {
    person = new Person();
    person.firstName = FIRST_NAME_1;
    person.lastName = LAST_NAME;
    person.birthDate = new Date(BIRTH_DATE_MILLIS);
    person.save();
    person = Person.get(1);
    assertNotNull(person);
    assertEqual(FIRST_NAME_1, person.firstName);
    assertEqual(LAST_NAME, person.lastName);
    assertEqual(new Date(BIRTH_DATE_MILLIS), person.birthDate);
};

exports.testPersistUpdating = function () {
    person = Person.all()[0];
    assertNotNull(person);
    person.firstName = FIRST_NAME_2;
    person.save();
    person = Person.get(1);
    assertNotNull(person);
    assertEqual(FIRST_NAME_2, person.firstName);
    assertEqual(LAST_NAME, person.lastName);
    assertEqual(new Date(BIRTH_DATE_MILLIS), person.birthDate);
};

exports.testBasicQuerying = function () {
    assertEqual(1, Person.all().length);
    assertEqual(LAST_NAME, Person.all()[0].lastName);
    assertEqual(LAST_NAME, Person.query().equals('lastName', LAST_NAME).
            select('lastName')[0]);
    assertEqual(1, Person.query().equals('lastName', LAST_NAME).select().
            length);
};

exports.testPersistDeletion = function () {
    person.remove();
    person = Person.get(1);
    assertNull(person);
    assertEqual(0, Person.all().length);
    fs.removeDirectory(fs.join(getRingoHome().path, 'db', 'Person'));
    fs.removeDirectory(fs.join(getRingoHome().path, 'db')); // Clean up.
};

@@ -79,27 +79,20 @@
 );%0Avar %7B
-getRingoHom
+Stor
 e%7D = req
@@ -107,65 +107,81 @@
 ngo/
-engine');%0Avar %7BStore%7D = require('ringo/storage/filestore'
+storage/filestore');%0Avar dbPath = fs.join(system.prefix, %22test%22, %22testdb%22
 );%0Av
@@ -201,20 +201,22 @@
 w Store(
-'
 db
-'
+Path
 );%0Avar p
@@ -1602,33 +1602,14 @@
 oin(
-getRingoHome().path, 'db'
+dbPath
 , 'P
@@ -1645,42 +1645,14 @@
 ory(
-fs.join(getRingoHome().path, 'db')
+dbPath
 ); /

Use test/testdb as directory for filestore tests rather than db in ringo-home