Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6,310 changes: 3,101 additions & 3,209 deletions services/super-admin/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion services/super-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"arango-tools": "0.2.3",
"arango-tools": "0.3.0",
"bcryptjs": "^2.4.3",
"dotenv-safe": "^8.2.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ describe('given the createSuperAdminAccount function', () => {
})
})
describe('given an unsuccessful creation', () => {
describe('transaction run error occurs', () => {
describe('transaction step error occurs', () => {
it('throws an error', async () => {
const mockedTransaction = jest.fn().mockReturnValueOnce({
run() {
step() {
throw new Error('Database error occurred.')
},
commit() {
Expand All @@ -76,7 +76,7 @@ describe('given the createSuperAdminAccount function', () => {
} catch (err) {
expect(err).toEqual(
new Error(
'Transaction run error occurred while creating new super admin account: Error: Database error occurred.',
'Transaction step error occurred while creating new super admin account: Error: Database error occurred.',
),
)
}
Expand All @@ -85,7 +85,7 @@ describe('given the createSuperAdminAccount function', () => {
describe('transaction commit error occurs', () => {
it('throws an error', async () => {
const mockedTransaction = jest.fn().mockReturnValueOnce({
run() {
step() {
return 'string'
},
commit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ describe('given the createSuperAdminAffiliation function', () => {
})
})
describe('given an unsuccessful creation', () => {
describe('transaction run error occurs', () => {
describe('transaction step error occurs', () => {
it('throws an error', async () => {
const mockedTransaction = jest.fn().mockReturnValueOnce({
run() {
step() {
throw new Error('Database error occurred.')
},
commit() {
Expand All @@ -89,7 +89,7 @@ describe('given the createSuperAdminAffiliation function', () => {
} catch (err) {
expect(err).toEqual(
new Error(
'Transaction run error occurred while creating new super admin affiliation: Error: Database error occurred.',
'Transaction step error occurred while creating new super admin affiliation: Error: Database error occurred.',
),
)
}
Expand All @@ -98,7 +98,7 @@ describe('given the createSuperAdminAffiliation function', () => {
describe('transaction commit error occurs', () => {
it('throws an error', async () => {
const mockedTransaction = jest.fn().mockReturnValueOnce({
run() {
step() {
return 'string'
},
commit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ describe('given the createSuperAdminOrg function', () => {
})
})
describe('given an unsuccessful creation', () => {
describe('transaction run error occurs', () => {
describe('transaction step error occurs', () => {
it('throws an error', async () => {
const mockedTransaction = jest.fn().mockReturnValueOnce({
run() {
step() {
throw new Error('Database error occurred.')
},
commit() {
Expand All @@ -73,7 +73,7 @@ describe('given the createSuperAdminOrg function', () => {
} catch (err) {
expect(err).toEqual(
new Error(
'Transaction run error occurred while creating new super admin org: Error: Database error occurred.',
'Transaction step error occurred while creating new super admin org: Error: Database error occurred.',
),
)
}
Expand All @@ -82,7 +82,7 @@ describe('given the createSuperAdminOrg function', () => {
describe('transaction commit error occurs', () => {
it('throws an error', async () => {
const mockedTransaction = jest.fn().mockReturnValueOnce({
run() {
step() {
return 'string'
},
commit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('given the removeSuperAdminAffiliation function', () => {
describe('database error occurs', () => {
it('throws an error', async () => {
const mockedTransaction = jest.fn().mockReturnValueOnce({
run() {
step() {
throw new Error('Database error occurred.')
},
commit() {
Expand All @@ -79,7 +79,7 @@ describe('given the removeSuperAdminAffiliation function', () => {
} catch (err) {
expect(err).toEqual(
new Error(
'Transaction run error occurred well removing super admin affiliation: Error: Database error occurred.',
'Transaction step error occurred well removing super admin affiliation: Error: Database error occurred.',
),
)
}
Expand All @@ -88,7 +88,7 @@ describe('given the removeSuperAdminAffiliation function', () => {
describe('cursor error occurs', () => {
it('throws an error', async () => {
const mockedTransaction = jest.fn().mockReturnValueOnce({
run() {
step() {
return 'string'
},
commit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const createSuperAdminAccount = async ({

let user
try {
await trx.run(async () => {
await trx.step(async () => {
user = await collections.users.save({
displayName: SA_USER_DISPLAY_NAME,
userName: SA_USER_USERNAME,
Expand All @@ -35,7 +35,7 @@ const createSuperAdminAccount = async ({
})
} catch (err) {
throw new Error(
`Transaction run error occurred while creating new super admin account: ${err}`,
`Transaction step error occurred while creating new super admin account: ${err}`,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const createSuperAdminAffiliation = async ({

let affiliation
try {
await trx.run(async () => {
await trx.step(async () => {
affiliation = await collections.affiliations.save({
_from: org._id,
_to: admin._id,
Expand All @@ -25,7 +25,7 @@ const createSuperAdminAffiliation = async ({
})
} catch (err) {
throw new Error(
`Transaction run error occurred while creating new super admin affiliation: ${err}`,
`Transaction step error occurred while creating new super admin affiliation: ${err}`,
)
}

Expand Down
4 changes: 2 additions & 2 deletions services/super-admin/src/database/create-super-admin-org.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const createSuperAdminOrg = async ({ collections, transaction }) => {

let org
try {
await trx.run(async () => {
await trx.step(async () => {
org = await collections.organizations.save({
verified: false,
orgDetails: {
Expand Down Expand Up @@ -58,7 +58,7 @@ const createSuperAdminOrg = async ({ collections, transaction }) => {
})
} catch (err) {
throw new Error(
`Transaction run error occurred while creating new super admin org: ${err}`,
`Transaction step error occurred while creating new super admin org: ${err}`,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const removeSuperAdminAffiliation = async ({
const trx = await transaction(collectionStrings)

try {
await trx.run(async () => {
await trx.step(async () => {
await query`
FOR affiliation IN affiliations
FILTER affiliation.defaultSA == true
Expand All @@ -23,7 +23,7 @@ const removeSuperAdminAffiliation = async ({
})
} catch (err) {
throw new Error(
`Transaction run error occurred well removing super admin affiliation: ${err}`,
`Transaction step error occurred well removing super admin affiliation: ${err}`,
)
}

Expand Down