mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
fixing test
This commit is contained in:
parent
611933f788
commit
2e1a0acf89
@ -101,7 +101,11 @@ export class SQLConnection {
|
||||
}
|
||||
version.version = DataStructureVersion;
|
||||
|
||||
const users = await connection.getRepository(UserEntity).find();
|
||||
let users: UserEntity[] = [];
|
||||
try {
|
||||
users = await connection.getRepository(UserEntity).createQueryBuilder('user').getMany();
|
||||
} catch (ex) {
|
||||
}
|
||||
await connection.dropDatabase();
|
||||
await connection.synchronize();
|
||||
await connection.getRepository(VersionEntity).save(version);
|
||||
|
@ -81,7 +81,6 @@ export class MetadataLoader {
|
||||
|
||||
try {
|
||||
const stat = fs.statSync(fullPath);
|
||||
console.log(stat);
|
||||
metadata.fileSize = stat.size;
|
||||
metadata.creationDate = stat.ctime.getTime();
|
||||
} catch (err) {
|
||||
|
@ -16,6 +16,8 @@ import {
|
||||
PositionMetaDataEntity
|
||||
} from '../../../../../backend/model/sql/enitites/PhotoEntity';
|
||||
import {MediaDimensionEntity} from '../../../../../backend/model/sql/enitites/MediaEntity';
|
||||
import {DataStructureVersion} from '../../../../../common/DataStructureVersion';
|
||||
import {VersionEntity} from '../../../../../backend/model/sql/enitites/VersionEntity';
|
||||
|
||||
describe('Typeorm integration', () => {
|
||||
|
||||
@ -104,6 +106,25 @@ describe('Typeorm integration', () => {
|
||||
return d;
|
||||
};
|
||||
|
||||
it('should migrate users', async () => {
|
||||
const conn = await SQLConnection.getConnection();
|
||||
const a = new UserEntity();
|
||||
a.name = 'migrated admin';
|
||||
a.password = PasswordHelper.cryptPassword('Test admin');
|
||||
a.role = UserRoles.Admin;
|
||||
await conn.getRepository(UserEntity).save(a);
|
||||
|
||||
const version = await conn.getRepository(VersionEntity).findOne();
|
||||
version.version--;
|
||||
await conn.getRepository(VersionEntity).save(version);
|
||||
|
||||
await SQLConnection.close();
|
||||
|
||||
const conn2 = await SQLConnection.getConnection();
|
||||
const admins = await conn2.getRepository(UserEntity).find({name: 'migrated admin'});
|
||||
expect(admins.length).to.be.equal(1);
|
||||
});
|
||||
|
||||
it('should open and close connection', async () => {
|
||||
const conn = await SQLConnection.getConnection();
|
||||
expect(conn.isConnected).to.equal(true);
|
||||
|
Loading…
Reference in New Issue
Block a user