mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
use correct logging categories
This commit is contained in:
parent
84862bce8b
commit
54782d95c3
@ -1,3 +0,0 @@
|
||||
import { LOG4JS_BASE_CATEGORY_NAME } from '../config/const'
|
||||
|
||||
export const LOG4JS_CATEGORY_SCHEMA_ALIAS = `${LOG4JS_BASE_CATEGORY_NAME}.schema`
|
||||
@ -1,10 +1,10 @@
|
||||
import { LOG4JS_CATEGORY_SCHEMA_ALIAS } from '.'
|
||||
import { validateAlias } from './user'
|
||||
import { getLogger, printLogs } from '../../../config-schema/test/testSetup.bun'
|
||||
import { getLogger } from '../../../config-schema/test/testSetup.bun'
|
||||
import { describe, it, expect, beforeEach, mock, jest } from 'bun:test'
|
||||
import { aliasExists } from 'database'
|
||||
import { LOG4JS_BASE_CATEGORY_NAME } from '../config/const'
|
||||
|
||||
const logger = getLogger(`${LOG4JS_CATEGORY_SCHEMA_ALIAS}.alias`)
|
||||
const logger = getLogger(`${LOG4JS_BASE_CATEGORY_NAME}.validation.user`)
|
||||
|
||||
mock.module('database', () => ({
|
||||
aliasExists: jest.fn(),
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { ZodError } from 'zod'
|
||||
import { getLogger } from 'log4js'
|
||||
import { LOG4JS_CATEGORY_SCHEMA_ALIAS } from '.'
|
||||
import { LOG4JS_BASE_CATEGORY_NAME } from '../config/const'
|
||||
import { aliasExists } from 'database'
|
||||
import { aliasSchema } from 'shared'
|
||||
|
||||
const logger = getLogger(`${LOG4JS_CATEGORY_SCHEMA_ALIAS}.alias`)
|
||||
const logger = getLogger(`${LOG4JS_BASE_CATEGORY_NAME}.validation.user`)
|
||||
|
||||
export async function validateAlias(alias: string): Promise<true> {
|
||||
try {
|
||||
|
||||
@ -41,4 +41,13 @@ describe('utils/decay', () => {
|
||||
const now = new Date()
|
||||
expect(calculateDecay(new Decimal(100.0), now, now).balance.toString()).toBe('100')
|
||||
})
|
||||
|
||||
describe('calculateDecay called with invalid dates', () => {
|
||||
it('throws an error when to is before from', () => {
|
||||
const now = new Date()
|
||||
const oneSecondAgo = new Date(now.getTime())
|
||||
oneSecondAgo.setSeconds(0)
|
||||
expect(() => calculateDecay(new Decimal(1.0), now, oneSecondAgo)).toThrowError()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,11 +1,7 @@
|
||||
import { Decimal } from 'decimal.js-light'
|
||||
|
||||
import { getLogger } from 'log4js'
|
||||
import { LOG4JS_LOGIC_CATEGORY } from '.'
|
||||
import { DECAY_START_TIME } from '../const'
|
||||
|
||||
const logger = getLogger(`${LOG4JS_LOGIC_CATEGORY}.DecayLogic`)
|
||||
|
||||
Decimal.set({
|
||||
precision: 25,
|
||||
rounding: Decimal.ROUND_HALF_UP,
|
||||
@ -40,7 +36,7 @@ export function calculateDecay(
|
||||
const startBlockMs = DECAY_START_TIME.getTime()
|
||||
|
||||
if (toMs < fromMs) {
|
||||
logger.error('calculateDecay: to < from, reverse decay calculation is invalid', from, to)
|
||||
// TODO: refactor, use custom Error Classes which contain context variables
|
||||
throw new Error('calculateDecay: to < from, reverse decay calculation is invalid')
|
||||
}
|
||||
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
import { LOG4JS_BASE_CATEGORY_NAME } from '../const'
|
||||
|
||||
export const LOG4JS_LOGIC_CATEGORY = `${LOG4JS_BASE_CATEGORY_NAME}.logic`
|
||||
Loading…
x
Reference in New Issue
Block a user