mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
fix lint and precise cascade
This commit is contained in:
parent
7d31626a40
commit
81dc6245ff
@ -7,13 +7,11 @@ import assert from 'assert'
|
||||
import { TransactionResult } from '@model/TransactionResult'
|
||||
import { AccountFactory } from '@/data/Account.factory'
|
||||
import { CONFIG } from '@/config'
|
||||
import { KeyManager } from '@/manager/KeyManager'
|
||||
import { UserFactory } from '@/data/User.factory'
|
||||
import { UserAccountDraft } from '../input/UserAccountDraft'
|
||||
import { UserLogic } from '@/data/User.logic'
|
||||
import { AccountType } from '../enum/AccountType'
|
||||
import { UserIdentifier } from '../input/UserIdentifier'
|
||||
import { KeyPair } from '@/data/KeyPair'
|
||||
import { CommunityDraft } from '../input/CommunityDraft'
|
||||
import { AddCommunityContext } from '@/interactions/backendToDb/community/AddCommunity.context'
|
||||
|
||||
@ -36,22 +34,22 @@ jest.mock('@typeorm/DataSource', () => ({
|
||||
const communityUUID = '3d813cbb-37fb-42ba-91df-831e1593ac29'
|
||||
|
||||
const createUserStoreAccount = async (uuid: string): Promise<UserIdentifier> => {
|
||||
const senderUserAccountDraft = new UserAccountDraft()
|
||||
senderUserAccountDraft.accountType = AccountType.COMMUNITY_HUMAN
|
||||
senderUserAccountDraft.createdAt = new Date().toString()
|
||||
senderUserAccountDraft.user = new UserIdentifier()
|
||||
senderUserAccountDraft.user.uuid = uuid
|
||||
senderUserAccountDraft.user.communityUuid = communityUUID
|
||||
const senderUser = UserFactory.create(senderUserAccountDraft)
|
||||
const senderUserLogic = new UserLogic(senderUser)
|
||||
const senderAccount = AccountFactory.createAccountFromUserAccountDraft(
|
||||
senderUserAccountDraft,
|
||||
senderUserLogic.calculateKeyPair(),
|
||||
const userAccountDraft = new UserAccountDraft()
|
||||
userAccountDraft.accountType = AccountType.COMMUNITY_HUMAN
|
||||
userAccountDraft.createdAt = new Date().toString()
|
||||
userAccountDraft.user = new UserIdentifier()
|
||||
userAccountDraft.user.uuid = uuid
|
||||
userAccountDraft.user.communityUuid = communityUUID
|
||||
const user = UserFactory.create(userAccountDraft)
|
||||
const userLogic = new UserLogic(user)
|
||||
const account = AccountFactory.createAccountFromUserAccountDraft(
|
||||
userAccountDraft,
|
||||
userLogic.calculateKeyPair(),
|
||||
)
|
||||
senderAccount.user = senderUser
|
||||
// user is set to cascade true will be saved together with account
|
||||
await senderAccount.save()
|
||||
return senderUserAccountDraft.user
|
||||
account.user = user
|
||||
// user is set to cascade: ['insert'] will be saved together with account
|
||||
await account.save()
|
||||
return userAccountDraft.user
|
||||
}
|
||||
|
||||
describe('Transaction Resolver Test', () => {
|
||||
|
||||
@ -3,7 +3,6 @@ import { ForeignCommunityRole } from './ForeignCommunity.role'
|
||||
import { HomeCommunityRole } from './HomeCommunity.role'
|
||||
import { iotaTopicFromCommunityUUID } from '@/utils/typeConverter'
|
||||
import { CommunityRole } from './Community.role'
|
||||
import { Community } from '@entity/Community'
|
||||
|
||||
/**
|
||||
* @DCI-Context
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { AccountRepository } from '@/data/Account.repository'
|
||||
import { KeyPair } from '@/data/KeyPair'
|
||||
import { TransactionBuilder } from '@/data/Transaction.builder'
|
||||
import { UserRepository } from '@/data/User.repository'
|
||||
|
||||
@ -53,7 +53,6 @@ export class Connection {
|
||||
}
|
||||
|
||||
public getDataSource(): DBDataSource {
|
||||
console.log('production getDataSource called!')
|
||||
return this.connection
|
||||
}
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ export class Account extends BaseEntity {
|
||||
@PrimaryGeneratedColumn('increment', { unsigned: true })
|
||||
id: number
|
||||
|
||||
@ManyToOne(() => User, (user) => user.accounts, { cascade: true, eager: true }) // Assuming you have a User entity with 'accounts' relation
|
||||
@ManyToOne(() => User, (user) => user.accounts, { cascade: ['insert'], eager: true }) // Assuming you have a User entity with 'accounts' relation
|
||||
@JoinColumn({ name: 'user_id' })
|
||||
user?: User
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user