|
@@ -16,22 +16,26 @@ if (process.env.NODE_ENV !== 'test') {
|
|
|
throw new Error('\'process.env.NODE_ENV\' must be \'test\'');
|
|
throw new Error('\'process.env.NODE_ENV\' must be \'test\'');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
|
|
|
-// const { getInstance } = require('./setup-crowi');
|
|
|
|
|
-
|
|
|
|
|
module.exports = async() => {
|
|
module.exports = async() => {
|
|
|
initMongooseGlobalSettings();
|
|
initMongooseGlobalSettings();
|
|
|
|
|
|
|
|
- await mongoose.connect(getMongoUri(), mongoOptions);
|
|
|
|
|
|
|
+ mongoose.connect(getMongoUri(), mongoOptions);
|
|
|
|
|
|
|
|
// drop database
|
|
// drop database
|
|
|
await mongoose.connection.dropDatabase();
|
|
await mongoose.connection.dropDatabase();
|
|
|
|
|
|
|
|
// init DB
|
|
// init DB
|
|
|
- // const crowi = await getInstance();
|
|
|
|
|
- // const appService = crowi.appService;
|
|
|
|
|
- // await appService.initDB();
|
|
|
|
|
|
|
+ const pageCollection = mongoose.connection.collection('pages');
|
|
|
|
|
+ const userCollection = mongoose.connection.collection('users');
|
|
|
|
|
+
|
|
|
|
|
+ // create global user & rootPage
|
|
|
|
|
+ const globalUser = (await userCollection.insertMany([{ name: 'globalUser', username: 'globalUser', email: 'globalUser@example.com' }]))[0];
|
|
|
|
|
+ await pageCollection.insertMany([{
|
|
|
|
|
+ path: '/',
|
|
|
|
|
+ grant: 1,
|
|
|
|
|
+ creator: globalUser,
|
|
|
|
|
+ lastUpdateUser: globalUser,
|
|
|
|
|
+ }]);
|
|
|
|
|
|
|
|
await mongoose.disconnect();
|
|
await mongoose.disconnect();
|
|
|
};
|
|
};
|