Skip to content

Commit

Permalink
fix(test): adjust test configs
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerald Baulig committed Nov 14, 2024
1 parent 4e285b9 commit 0d6ba9e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 31 deletions.
28 changes: 11 additions & 17 deletions cfg/config_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"resourcesProtoPathPrefix": "io/restorecommerce/",
"resourcesServiceNamePrefix": "io.restorecommerce.",
"resourcesServiceConfigPrefix": "restore-",
"resourcesDeletedMessage": "io.restorecommerce.resourcebase.Deleted",
"resources": [
{
"resourceName": "command",
Expand All @@ -63,7 +64,7 @@
}
},
"graph": {
"graphName": "resource-srv-graph",
"graphName": "resource-srv-graph-test",
"vertices": {
"organizations": [
{
Expand Down Expand Up @@ -195,26 +196,25 @@
]
},
"fieldHandlers": {
"fieldGenerators": {},
"bufferFields": {
"organizations": ["data"],
"locations": ["data"],
"credentials": ["credentials"]
"organization": ["data"],
"location": ["data"],
"credential": ["credentials"]
},
"requiredFields": {},
"timeStampFields": [
{
"fields": [
"meta.created",
"meta.modified"
],
"entities": [
"commands",
"organizations",
"contact_points"
"command",
"organization",
"contact_point"
]
}
]
],
"requiredFields": null
},
"client": {
"default-resource-srv": {
Expand Down Expand Up @@ -243,11 +243,5 @@
"code": "403",
"message": "Action not allowed on this resource"
}
},
"techUsers": [
{
"id": "upsert_user_tokens",
"token": "change.this.token.number"
}
]
}
}
23 changes: 18 additions & 5 deletions test/resource_srv.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@ import { Worker } from '../src/worker.js';
import { updateConfig } from '@restorecommerce/acs-client';
import { createLogger } from '@restorecommerce/logger';
import { createServiceConfig } from '@restorecommerce/service-config';
import { CommandInterfaceServiceDefinition, CommandInterfaceServiceClient as cisClient } from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/commandinterface.js';
import { CommandServiceDefinition as command } from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/command.js';
import { OrganizationServiceDefinition as organization, protoMetadata as organizationMeta } from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/organization.js';
import { ContactPointServiceDefinition as contact_point } from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/contact_point.js';
import { CommandInterfaceServiceDefinition } from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/commandinterface.js';
import {
CommandServiceDefinition as command,
protoMetadata as commandPointMeta
} from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/command.js';
import {
OrganizationServiceDefinition as organization,
protoMetadata as organizationMeta
} from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/organization.js';
import {
ContactPointServiceDefinition as contact_point,
protoMetadata as contactPointMeta
} from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/contact_point.js';
import { ReadRequest, Sort_SortOrder } from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/resource_base.js';
import { Filter_Operation } from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/filter.js';

Expand All @@ -18,7 +27,11 @@ const logger = createLogger(cfg.get('logger'));
const ServiceDefinitionList = [command, organization, contact_point];

// for test `should re read messages for organization resource` (since a local listener for Organization events is created in unit test below)
registerProtoMeta(organizationMeta);
registerProtoMeta(
organizationMeta,
contactPointMeta,
commandPointMeta
);

/**
* Note: To run below tests a running Kafka, Redis and ArangoDB instance is required.
Expand Down
32 changes: 23 additions & 9 deletions test/resource_srv_acs.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
import {} from 'mocha';
import should from 'should';
import { createChannel, createClient } from '@restorecommerce/grpc-client';
import { Events, Topic } from '@restorecommerce/kafka-client';
import { Events, Topic, registerProtoMeta } from '@restorecommerce/kafka-client';
import { Worker } from '../src/worker.js';
import { GrpcMockServer, ProtoUtils } from '@alenon/grpc-mock-server';
import * as proto_loader from '@grpc/proto-loader';
import * as grpc from '@grpc/grpc-js';
import { createLogger } from '@restorecommerce/logger';
import { createServiceConfig } from '@restorecommerce/service-config';
import { CommandInterfaceServiceDefinition, CommandInterfaceServiceClient as cisClient } from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/commandinterface.js';
import { CommandServiceDefinition as command } from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/command.js';
import { OrganizationServiceDefinition as organization } from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/organization.js';
import { ContactPointServiceDefinition as contact_point } from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/contact_point.js';
import { createClient as RedisCreateClient, RedisClientType } from 'redis';
import { CommandInterfaceServiceDefinition } from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/commandinterface.js';
import {
CommandServiceDefinition as command,
protoMetadata as commandPointMeta
} from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/command.js';
import {
OrganizationServiceDefinition as organization,
protoMetadata as organizationMeta
} from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/organization.js';
import {
ContactPointServiceDefinition as contact_point,
protoMetadata as contactPointMeta
} from '@restorecommerce/rc-grpc-clients/dist/generated-server/io/restorecommerce/contact_point.js';import { createClient as RedisCreateClient, RedisClientType } from 'redis';
import { updateConfig } from '@restorecommerce/acs-client';

registerProtoMeta(
organizationMeta,
contactPointMeta,
commandPointMeta
);

const cfg = createServiceConfig(process.cwd());
const logger = createLogger(cfg.get('logger'));
const ServiceDefinitionList = [command, organization, contact_point];
Expand Down Expand Up @@ -307,10 +321,10 @@ describe('resource-srv testing with ACS enabled', () => {
// List of serviceMappedValues
const serviceMapping = await getClientResourceServices();
// get the Organization service
let orgMapValue = serviceMapping.microservice.mapClients.get('organization');
const orgMapValue = serviceMapping.microservice.mapClients.get('organization');
organizationService = serviceMapping.microservice.service[orgMapValue];
// get contact_point service
let contacPointMapValue = serviceMapping.microservice.mapClients.get('contact_point');
const contacPointMapValue = serviceMapping.microservice.mapClients.get('contact_point');
contactPointsService = serviceMapping.microservice.service[contacPointMapValue];

// create events for restoring
Expand All @@ -320,7 +334,7 @@ describe('resource-srv testing with ACS enabled', () => {
commandTopic = await events.topic(cfg.get('events:kafka:topics:command:topic'));

// create command service
let commandMapValue = serviceMapping.microservice.mapClients.get('command');
const commandMapValue = serviceMapping.microservice.mapClients.get('command');
commandService = serviceMapping.microservice.service[commandMapValue];
});

Expand Down

0 comments on commit 0d6ba9e

Please sign in to comment.