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;
|
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.dropDatabase();
|
||||||
await connection.synchronize();
|
await connection.synchronize();
|
||||||
await connection.getRepository(VersionEntity).save(version);
|
await connection.getRepository(VersionEntity).save(version);
|
||||||
|
@ -81,7 +81,6 @@ export class MetadataLoader {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const stat = fs.statSync(fullPath);
|
const stat = fs.statSync(fullPath);
|
||||||
console.log(stat);
|
|
||||||
metadata.fileSize = stat.size;
|
metadata.fileSize = stat.size;
|
||||||
metadata.creationDate = stat.ctime.getTime();
|
metadata.creationDate = stat.ctime.getTime();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -16,6 +16,8 @@ import {
|
|||||||
PositionMetaDataEntity
|
PositionMetaDataEntity
|
||||||
} from '../../../../../backend/model/sql/enitites/PhotoEntity';
|
} from '../../../../../backend/model/sql/enitites/PhotoEntity';
|
||||||
import {MediaDimensionEntity} from '../../../../../backend/model/sql/enitites/MediaEntity';
|
import {MediaDimensionEntity} from '../../../../../backend/model/sql/enitites/MediaEntity';
|
||||||
|
import {DataStructureVersion} from '../../../../../common/DataStructureVersion';
|
||||||
|
import {VersionEntity} from '../../../../../backend/model/sql/enitites/VersionEntity';
|
||||||
|
|
||||||
describe('Typeorm integration', () => {
|
describe('Typeorm integration', () => {
|
||||||
|
|
||||||
@ -104,6 +106,25 @@ describe('Typeorm integration', () => {
|
|||||||
return d;
|
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 () => {
|
it('should open and close connection', async () => {
|
||||||
const conn = await SQLConnection.getConnection();
|
const conn = await SQLConnection.getConnection();
|
||||||
expect(conn.isConnected).to.equal(true);
|
expect(conn.isConnected).to.equal(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user