mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-26 13:48:33 +02:00
fix: refactor event types
This commit is contained in:
parent
88a56b8569
commit
df2e23c282
@ -3,7 +3,7 @@ const {
|
||||
FEATURE_UPDATED,
|
||||
FEATURE_ARCHIVED,
|
||||
FEATURE_REVIVED,
|
||||
} = require('../event-type');
|
||||
} = require('../types/events');
|
||||
|
||||
module.exports = {
|
||||
name: 'jira-comment',
|
||||
|
@ -7,7 +7,7 @@ const {
|
||||
FEATURE_UPDATED,
|
||||
FEATURE_REVIVED,
|
||||
FEATURE_ARCHIVED,
|
||||
} = require('../event-type');
|
||||
} = require('../types/events');
|
||||
|
||||
class JiraAddon extends Addon {
|
||||
constructor(args) {
|
||||
|
@ -7,7 +7,7 @@ const {
|
||||
FEATURE_REVIVED,
|
||||
FEATURE_STALE_ON,
|
||||
FEATURE_STALE_OFF,
|
||||
} = require('../event-type');
|
||||
} = require('../types/events');
|
||||
|
||||
module.exports = {
|
||||
name: 'slack',
|
||||
|
@ -10,7 +10,7 @@ const {
|
||||
FEATURE_REVIVED,
|
||||
FEATURE_STALE_ON,
|
||||
FEATURE_STALE_OFF,
|
||||
} = require('../event-type');
|
||||
} = require('../types/events');
|
||||
|
||||
const definition = require('./slack-definition');
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
const test = require('ava');
|
||||
const proxyquire = require('proxyquire').noCallThru();
|
||||
const { FEATURE_CREATED, FEATURE_ARCHIVED } = require('../event-type');
|
||||
const { FEATURE_CREATED, FEATURE_ARCHIVED } = require('../types/events');
|
||||
|
||||
const SlackAddon = proxyquire.load('./slack', {
|
||||
'./addon': class Addon {
|
||||
|
@ -7,7 +7,7 @@ const {
|
||||
FEATURE_REVIVED,
|
||||
FEATURE_STALE_ON,
|
||||
FEATURE_STALE_OFF,
|
||||
} = require('../event-type');
|
||||
} = require('../types/events');
|
||||
|
||||
module.exports = {
|
||||
name: 'teams',
|
||||
|
@ -10,7 +10,7 @@ const {
|
||||
FEATURE_REVIVED,
|
||||
FEATURE_STALE_ON,
|
||||
FEATURE_STALE_OFF,
|
||||
} = require('../event-type');
|
||||
} = require('../types/events');
|
||||
|
||||
const definition = require('./teams-definition');
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
const test = require('ava');
|
||||
const proxyquire = require('proxyquire').noCallThru();
|
||||
const { FEATURE_CREATED, FEATURE_ARCHIVED } = require('../event-type');
|
||||
const { FEATURE_CREATED, FEATURE_ARCHIVED } = require('../types/events');
|
||||
|
||||
const TeamsAddon = proxyquire.load('./teams', {
|
||||
'./addon': class Addon {
|
||||
|
@ -5,7 +5,7 @@ const {
|
||||
FEATURE_REVIVED,
|
||||
FEATURE_STALE_ON,
|
||||
FEATURE_STALE_OFF,
|
||||
} = require('../event-type');
|
||||
} = require('../types/events');
|
||||
|
||||
module.exports = {
|
||||
name: 'webhook',
|
||||
|
@ -1,6 +1,6 @@
|
||||
const test = require('ava');
|
||||
const proxyquire = require('proxyquire').noCallThru();
|
||||
const { FEATURE_CREATED } = require('../event-type');
|
||||
const { FEATURE_CREATED } = require('../types/events');
|
||||
|
||||
const WebhookAddon = proxyquire.load('./webhook', {
|
||||
'./addon': class Addon {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { Knex } from 'knex';
|
||||
import metricsHelper from '../metrics-helper';
|
||||
import { DB_TIME } from '../events';
|
||||
import { DB_TIME } from '../metric-events';
|
||||
|
||||
const T = {
|
||||
ROLE_USER: 'role_user',
|
||||
|
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const metricsHelper = require('../metrics-helper');
|
||||
const { DB_TIME } = require('../events');
|
||||
const { DB_TIME } = require('../metric-events');
|
||||
const NotFoundError = require('../error/notfound-error');
|
||||
|
||||
const COLUMNS = [
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { Knex } from 'knex';
|
||||
import metricsHelper from '../metrics-helper';
|
||||
import { DB_TIME } from '../events';
|
||||
import { DB_TIME } from '../metric-events';
|
||||
import { Logger, LogProvider } from '../logger';
|
||||
import NotFoundError from '../error/notfound-error';
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
'use strict';
|
||||
|
||||
const metricsHelper = require('../metrics-helper');
|
||||
const { DB_TIME } = require('../events');
|
||||
const { DB_TIME } = require('../metric-events');
|
||||
|
||||
const COLUMNS = [
|
||||
'app_name',
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
const { EventEmitter } = require('events');
|
||||
const metricsHelper = require('../metrics-helper');
|
||||
const { DB_TIME } = require('../events');
|
||||
const { DB_TIME } = require('../metric-events');
|
||||
|
||||
const TEN_SECONDS = 10 * 1000;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { Knex } from 'knex';
|
||||
import { DROP_FEATURES } from '../event-type';
|
||||
import { DROP_FEATURES } from '../types/events';
|
||||
import { LogProvider, Logger } from '../logger';
|
||||
|
||||
const EVENT_COLUMNS = [
|
||||
|
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const metricsHelper = require('../metrics-helper');
|
||||
const { DB_TIME } = require('../events');
|
||||
const { DB_TIME } = require('../metric-events');
|
||||
const NotFoundError = require('../error/notfound-error');
|
||||
const FeatureHasTagError = require('../error/feature-has-tag-error');
|
||||
const { UNIQUE_CONSTRAINT_VIOLATION } = require('../error/db-error');
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { Knex } from 'knex';
|
||||
import metricsHelper from '../metrics-helper';
|
||||
import { DB_TIME } from '../events';
|
||||
import { DB_TIME } from '../metric-events';
|
||||
import { Logger, LogProvider } from '../logger';
|
||||
import NotFoundError from '../error/notfound-error';
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
import { Knex } from 'knex';
|
||||
import { EventEmitter } from 'events';
|
||||
import { DB_TIME } from '../events';
|
||||
import { DB_TIME } from '../metric-events';
|
||||
import metricsHelper from '../metrics-helper';
|
||||
import { LogProvider, Logger } from '../logger';
|
||||
import NotFoundError from '../error/notfound-error';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Knex } from 'knex';
|
||||
import { EventEmitter } from 'events';
|
||||
import { LogProvider, Logger } from '../logger';
|
||||
import { DB_TIME } from '../events';
|
||||
import { DB_TIME } from '../metric-events';
|
||||
import metricsHelper from '../metrics-helper';
|
||||
import NotFoundError from '../error/notfound-error';
|
||||
|
||||
|
@ -35,7 +35,7 @@ const {
|
||||
USER_CREATED,
|
||||
USER_UPDATED,
|
||||
USER_DELETED,
|
||||
} = require('./event-type');
|
||||
} = require('./types/events');
|
||||
|
||||
const strategyTypes = [
|
||||
STRATEGY_CREATED,
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
const test = require('ava');
|
||||
const eventDiffer = require('./event-differ');
|
||||
const { FEATURE_CREATED, FEATURE_UPDATED } = require('./event-type');
|
||||
const { FEATURE_CREATED, FEATURE_UPDATED } = require('./types/events');
|
||||
|
||||
test('should not fail if events include an unknown event type', t => {
|
||||
const events = [
|
||||
|
@ -5,7 +5,7 @@ const {
|
||||
FEATURE_UPDATED,
|
||||
FEATURE_ARCHIVED,
|
||||
FEATURE_REVIVED,
|
||||
} = require('./event-type');
|
||||
} = require('./types/events');
|
||||
|
||||
exports.addEventHook = (eventHook, eventStore) => {
|
||||
eventStore.on(FEATURE_CREATED, data => {
|
||||
|
@ -10,7 +10,7 @@ const {
|
||||
FEATURE_UPDATED,
|
||||
FEATURE_ARCHIVED,
|
||||
FEATURE_REVIVED,
|
||||
} = require('./event-type');
|
||||
} = require('./types/events');
|
||||
|
||||
const o = {};
|
||||
|
||||
|
@ -1,48 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
APPLICATION_CREATED: 'application-created',
|
||||
FEATURE_CREATED: 'feature-created',
|
||||
FEATURE_UPDATED: 'feature-updated',
|
||||
FEATURE_ARCHIVED: 'feature-archived',
|
||||
FEATURE_REVIVED: 'feature-revived',
|
||||
FEATURE_IMPORT: 'feature-import',
|
||||
FEATURE_TAGGED: 'feature-tagged',
|
||||
FEATURE_TAG_IMPORT: 'feature-tag-import',
|
||||
DROP_FEATURE_TAGS: 'drop-feature-tags',
|
||||
FEATURE_UNTAGGED: 'feature-untagged',
|
||||
FEATURE_STALE_ON: 'feature-stale-on',
|
||||
FEATURE_STALE_OFF: 'feature-stale-off',
|
||||
DROP_FEATURES: 'drop-features',
|
||||
STRATEGY_CREATED: 'strategy-created',
|
||||
STRATEGY_DELETED: 'strategy-deleted',
|
||||
STRATEGY_DEPRECATED: 'strategy-deprecated',
|
||||
STRATEGY_REACTIVATED: 'strategy-reactivated',
|
||||
STRATEGY_UPDATED: 'strategy-updated',
|
||||
STRATEGY_IMPORT: 'strategy-import',
|
||||
DROP_STRATEGIES: 'drop-strategies',
|
||||
CONTEXT_FIELD_CREATED: 'context-field-created',
|
||||
CONTEXT_FIELD_UPDATED: 'context-field-updated',
|
||||
CONTEXT_FIELD_DELETED: 'context-field-deleted',
|
||||
PROJECT_CREATED: 'project-created',
|
||||
PROJECT_UPDATED: 'project-updated',
|
||||
PROJECT_DELETED: 'project-deleted',
|
||||
PROJECT_IMPORT: 'project-import',
|
||||
DROP_PROJECTS: 'drop-projects',
|
||||
TAG_CREATED: 'tag-created',
|
||||
TAG_DELETED: 'tag-deleted',
|
||||
TAG_IMPORT: 'tag-import',
|
||||
DROP_TAGS: 'drop-tags',
|
||||
TAG_TYPE_CREATED: 'tag-type-created',
|
||||
TAG_TYPE_DELETED: 'tag-type-deleted',
|
||||
TAG_TYPE_UPDATED: 'tag-type-updated',
|
||||
TAG_TYPE_IMPORT: 'tag-type-import',
|
||||
DROP_TAG_TYPES: 'drop-tag-types',
|
||||
ADDON_CONFIG_CREATED: 'addon-config-created',
|
||||
ADDON_CONFIG_UPDATED: 'addon-config-updated',
|
||||
ADDON_CONFIG_DELETED: 'addon-config-deleted',
|
||||
DB_POOL_UPDATE: 'db-pool-update',
|
||||
USER_CREATED: 'user-created',
|
||||
USER_UPDATED: 'user-updated',
|
||||
USER_DELETED: 'user-deleted',
|
||||
};
|
@ -9,8 +9,8 @@ const eventStore = new EventEmitter();
|
||||
const clientMetricsStore = new EventEmitter();
|
||||
const { register: prometheusRegister } = require('prom-client');
|
||||
const { createTestConfig } = require('../test/config/test-config');
|
||||
const { REQUEST_TIME, DB_TIME } = require('./events');
|
||||
const { FEATURE_UPDATED } = require('./event-type');
|
||||
const { REQUEST_TIME, DB_TIME } = require('./metric-events');
|
||||
const { FEATURE_UPDATED } = require('./types/events');
|
||||
const { createMetricsMonitor } = require('./metrics');
|
||||
|
||||
const monitor = createMetricsMonitor();
|
||||
|
@ -1,14 +1,14 @@
|
||||
import client from 'prom-client';
|
||||
import EventEmitter from 'events';
|
||||
import { Knex } from 'knex';
|
||||
import * as events from './events';
|
||||
import * as events from './metric-events';
|
||||
import {
|
||||
FEATURE_CREATED,
|
||||
FEATURE_UPDATED,
|
||||
FEATURE_ARCHIVED,
|
||||
FEATURE_REVIVED,
|
||||
DB_POOL_UPDATE,
|
||||
} from './event-type';
|
||||
} from './types/events';
|
||||
import { IUnleashConfig } from './types/option';
|
||||
import { IUnleashStores } from './types/stores';
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as responseTime from 'response-time';
|
||||
import EventEmitter from 'events';
|
||||
import { REQUEST_TIME } from '../events';
|
||||
import { REQUEST_TIME } from '../metric-events';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
const _responseTime = responseTime.default;
|
||||
|
@ -14,7 +14,7 @@ import User from './types/user';
|
||||
|
||||
import permissions from './permissions';
|
||||
import AuthenticationRequired from './types/authentication-required';
|
||||
import eventType from './event-type';
|
||||
import * as eventType from './types/events';
|
||||
import { addEventHook } from './event-hook';
|
||||
|
||||
async function closeServer(opts): Promise<void> {
|
||||
|
@ -3,7 +3,7 @@
|
||||
const memoize = require('memoizee');
|
||||
const { ValidationError } = require('joi');
|
||||
const addonProvidersClasses = require('../addons');
|
||||
const events = require('../event-type');
|
||||
const events = require('../types/events');
|
||||
const { addonSchema } = require('./addon-schema');
|
||||
const NameExistsError = require('../error/name-exists-error');
|
||||
|
||||
|
@ -16,7 +16,7 @@ const {
|
||||
ADDON_CONFIG_CREATED,
|
||||
ADDON_CONFIG_UPDATED,
|
||||
ADDON_CONFIG_DELETED,
|
||||
} = require('../event-type');
|
||||
} = require('../types/events');
|
||||
|
||||
const MASKED_VALUE = '*****';
|
||||
|
||||
|
@ -7,7 +7,7 @@ const TTLList = require('./ttl-list.js');
|
||||
const appSchema = require('./metrics-schema');
|
||||
const { clientMetricsSchema } = require('./client-metrics-schema');
|
||||
const { clientRegisterSchema } = require('./register-schema');
|
||||
const { APPLICATION_CREATED } = require('../../event-type');
|
||||
const { APPLICATION_CREATED } = require('../../types/events');
|
||||
|
||||
const FIVE_SECONDS = 5 * 1000;
|
||||
const FIVE_MINUTES = 5 * 60 * 1000;
|
||||
|
@ -1,4 +1,4 @@
|
||||
const { FEATURE_TAGGED, FEATURE_UNTAGGED } = require('../event-type');
|
||||
const { FEATURE_TAGGED, FEATURE_UNTAGGED } = require('../types/events');
|
||||
const { featureSchema, nameSchema, querySchema } = require('./feature-schema');
|
||||
const { tagSchema } = require('./tag-schema');
|
||||
const NameExistsError = require('../error/name-exists-error');
|
||||
@ -11,7 +11,7 @@ const {
|
||||
FEATURE_STALE_ON,
|
||||
FEATURE_STALE_OFF,
|
||||
TAG_CREATED,
|
||||
} = require('../event-type');
|
||||
} = require('../types/events');
|
||||
|
||||
export default class FeatureToggleService {
|
||||
constructor({ featureToggleStore, tagStore, eventStore }, { getLogger }) {
|
||||
|
@ -4,12 +4,16 @@ import ProjectStore, { IProject } from '../db/project-store';
|
||||
import EventStore from '../db/event-store';
|
||||
import NameExistsError from '../error/name-exists-error';
|
||||
import InvalidOperationError from '../error/invalid-operation-error';
|
||||
import eventType from '../event-type';
|
||||
import { nameType } from '../routes/admin-api/util';
|
||||
import schema from './project-schema';
|
||||
import NotFoundError from '../error/notfound-error';
|
||||
import FeatureToggleStore from '../db/feature-toggle-store';
|
||||
import { IRole } from '../db/access-store';
|
||||
import {
|
||||
PROJECT_CREATED,
|
||||
PROJECT_DELETED,
|
||||
PROJECT_UPDATED,
|
||||
} from '../types/events';
|
||||
|
||||
const getCreatedBy = (user: User) => user.email || user.username;
|
||||
|
||||
@ -60,7 +64,7 @@ export default class ProjectService {
|
||||
await this.accessService.createDefaultProjectRoles(user, data.id);
|
||||
|
||||
await this.eventStore.store({
|
||||
type: eventType.PROJECT_CREATED,
|
||||
type: PROJECT_CREATED,
|
||||
createdBy: getCreatedBy(user),
|
||||
data,
|
||||
});
|
||||
@ -75,7 +79,7 @@ export default class ProjectService {
|
||||
await this.projectStore.update(project);
|
||||
|
||||
await this.eventStore.store({
|
||||
type: eventType.PROJECT_UPDATED,
|
||||
type: PROJECT_UPDATED,
|
||||
createdBy: getCreatedBy(user),
|
||||
data: project,
|
||||
});
|
||||
@ -102,7 +106,7 @@ export default class ProjectService {
|
||||
await this.projectStore.delete(id);
|
||||
|
||||
await this.eventStore.store({
|
||||
type: eventType.PROJECT_DELETED,
|
||||
type: PROJECT_DELETED,
|
||||
createdBy: getCreatedBy(user),
|
||||
data: { id },
|
||||
});
|
||||
|
@ -12,7 +12,7 @@ const {
|
||||
DROP_TAG_TYPES,
|
||||
PROJECT_IMPORT,
|
||||
DROP_PROJECTS,
|
||||
} = require('../event-type');
|
||||
} = require('../types/events');
|
||||
|
||||
const {
|
||||
readFile,
|
||||
|
@ -16,7 +16,7 @@ const {
|
||||
TAG_IMPORT,
|
||||
FEATURE_TAG_IMPORT,
|
||||
PROJECT_IMPORT,
|
||||
} = require('../event-type');
|
||||
} = require('../types/events');
|
||||
|
||||
function getSetup() {
|
||||
const stores = store.createStores();
|
||||
|
@ -2,7 +2,7 @@ import { tagSchema } from './tag-schema';
|
||||
import TagStore, { ITag } from '../db/tag-store';
|
||||
import EventStore from '../db/event-store';
|
||||
import NameExistsError from '../error/name-exists-error';
|
||||
import { TAG_CREATED, TAG_DELETED } from '../event-type';
|
||||
import { TAG_CREATED, TAG_DELETED } from '../types/events';
|
||||
import { Logger } from '../logger';
|
||||
|
||||
export default class TagService {
|
||||
|
@ -6,7 +6,7 @@ import {
|
||||
TAG_TYPE_CREATED,
|
||||
TAG_TYPE_DELETED,
|
||||
TAG_TYPE_UPDATED,
|
||||
} from '../event-type';
|
||||
} from '../types/events';
|
||||
import EventStore from '../db/event-store';
|
||||
import { Logger } from '../logger';
|
||||
import TagTypeStore, { ITagType } from '../db/tag-type-store';
|
||||
|
@ -20,7 +20,7 @@ import { IUnleashServices } from '../types/services';
|
||||
import { IUnleashStores } from '../types/stores';
|
||||
import PasswordUndefinedError from '../error/password-undefined';
|
||||
import EventStore from '../db/event-store';
|
||||
import { USER_UPDATED, USER_CREATED, USER_DELETED } from '../event-type';
|
||||
import { USER_UPDATED, USER_CREATED, USER_DELETED } from '../types/events';
|
||||
|
||||
const systemUser = new User({ id: -1, username: 'system' });
|
||||
|
||||
|
44
src/lib/types/events.ts
Normal file
44
src/lib/types/events.ts
Normal file
@ -0,0 +1,44 @@
|
||||
export const APPLICATION_CREATED = 'application-created';
|
||||
export const FEATURE_CREATED = 'feature-created';
|
||||
export const FEATURE_UPDATED = 'feature-updated';
|
||||
export const FEATURE_ARCHIVED = 'feature-archived';
|
||||
export const FEATURE_REVIVED = 'feature-revived';
|
||||
export const FEATURE_IMPORT = 'feature-import';
|
||||
export const FEATURE_TAGGED = 'feature-tagged';
|
||||
export const FEATURE_TAG_IMPORT = 'feature-tag-import';
|
||||
export const DROP_FEATURE_TAGS = 'drop-feature-tags';
|
||||
export const FEATURE_UNTAGGED = 'feature-untagged';
|
||||
export const FEATURE_STALE_ON = 'feature-stale-on';
|
||||
export const FEATURE_STALE_OFF = 'feature-stale-off';
|
||||
export const DROP_FEATURES = 'drop-features';
|
||||
export const STRATEGY_CREATED = 'strategy-created';
|
||||
export const STRATEGY_DELETED = 'strategy-deleted';
|
||||
export const STRATEGY_DEPRECATED = 'strategy-deprecated';
|
||||
export const STRATEGY_REACTIVATED = 'strategy-reactivated';
|
||||
export const STRATEGY_UPDATED = 'strategy-updated';
|
||||
export const STRATEGY_IMPORT = 'strategy-import';
|
||||
export const DROP_STRATEGIES = 'drop-strategies';
|
||||
export const CONTEXT_FIELD_CREATED = 'context-field-created';
|
||||
export const CONTEXT_FIELD_UPDATED = 'context-field-updated';
|
||||
export const CONTEXT_FIELD_DELETED = 'context-field-deleted';
|
||||
export const PROJECT_CREATED = 'project-created';
|
||||
export const PROJECT_UPDATED = 'project-updated';
|
||||
export const PROJECT_DELETED = 'project-deleted';
|
||||
export const PROJECT_IMPORT = 'project-import';
|
||||
export const DROP_PROJECTS = 'drop-projects';
|
||||
export const TAG_CREATED = 'tag-created';
|
||||
export const TAG_DELETED = 'tag-deleted';
|
||||
export const TAG_IMPORT = 'tag-import';
|
||||
export const DROP_TAGS = 'drop-tags';
|
||||
export const TAG_TYPE_CREATED = 'tag-type-created';
|
||||
export const TAG_TYPE_DELETED = 'tag-type-deleted';
|
||||
export const TAG_TYPE_UPDATED = 'tag-type-updated';
|
||||
export const TAG_TYPE_IMPORT = 'tag-type-import';
|
||||
export const DROP_TAG_TYPES = 'drop-tag-types';
|
||||
export const ADDON_CONFIG_CREATED = 'addon-config-created';
|
||||
export const ADDON_CONFIG_UPDATED = 'addon-config-updated';
|
||||
export const ADDON_CONFIG_DELETED = 'addon-config-deleted';
|
||||
export const DB_POOL_UPDATE = 'db-pool-update';
|
||||
export const USER_CREATED = 'user-created';
|
||||
export const USER_UPDATED = 'user-updated';
|
||||
export const USER_DELETED = 'user-deleted';
|
@ -7,7 +7,11 @@ import UserStore from '../../../../lib/db/user-store';
|
||||
import { AccessStore, IRole } from '../../../../lib/db/access-store';
|
||||
import { RoleName } from '../../../../lib/services/access-service';
|
||||
import EventStore from '../../../../lib/db/event-store';
|
||||
import eventType from '../../../../lib/event-type';
|
||||
import {
|
||||
USER_CREATED,
|
||||
USER_DELETED,
|
||||
USER_UPDATED,
|
||||
} from '../../../../lib/types/events';
|
||||
|
||||
let stores;
|
||||
let db;
|
||||
@ -265,7 +269,7 @@ test.serial('generates USER_CREATED event', async t => {
|
||||
|
||||
const events = await eventStore.getEvents();
|
||||
|
||||
t.is(events[0].type, eventType.USER_CREATED);
|
||||
t.is(events[0].type, USER_CREATED);
|
||||
t.is(events[0].data.email, email);
|
||||
t.is(events[0].data.name, name);
|
||||
t.is(events[0].data.id, body.id);
|
||||
@ -280,7 +284,7 @@ test.serial('generates USER_DELETED event', async t => {
|
||||
await request.delete(`/api/admin/user-admin/${user.id}`);
|
||||
|
||||
const events = await eventStore.getEvents();
|
||||
t.is(events[0].type, eventType.USER_DELETED);
|
||||
t.is(events[0].type, USER_DELETED);
|
||||
t.is(events[0].data.id, user.id);
|
||||
t.is(events[0].data.email, user.email);
|
||||
});
|
||||
@ -305,7 +309,7 @@ test.serial('generates USER_UPDATED event', async t => {
|
||||
.set('Content-Type', 'application/json');
|
||||
|
||||
const events = await eventStore.getEvents();
|
||||
t.is(events[0].type, eventType.USER_UPDATED);
|
||||
t.is(events[0].type, USER_UPDATED);
|
||||
t.is(events[0].data.id, body.id);
|
||||
t.is(events[0].data.name, 'New name');
|
||||
});
|
||||
|
@ -3,7 +3,7 @@ const faker = require('faker');
|
||||
const dbInit = require('../helpers/database-init');
|
||||
const getLogger = require('../../fixtures/no-logger');
|
||||
const ClientMetricsService = require('../../../lib/services/client-metrics');
|
||||
const { APPLICATION_CREATED } = require('../../../lib/event-type');
|
||||
const { APPLICATION_CREATED } = require('../../../lib/types/events');
|
||||
|
||||
let stores;
|
||||
let db;
|
||||
|
@ -5,7 +5,7 @@ const sinon = require('sinon');
|
||||
const {
|
||||
APPLICATION_CREATED,
|
||||
FEATURE_CREATED,
|
||||
} = require('../../../lib/event-type');
|
||||
} = require('../../../lib/types/events');
|
||||
|
||||
const dbInit = require('../helpers/database-init');
|
||||
const getLogger = require('../../fixtures/no-logger');
|
||||
|
Loading…
Reference in New Issue
Block a user