Skip to content

Commit

Permalink
Merge pull request #37 from RnDAO/feature/35-new-choreography-discord…
Browse files Browse the repository at this point in the history
…_fetch_members

Feature/35 new choreography discord fetch members
  • Loading branch information
scientiststwin authored Jun 15, 2023
2 parents b9d418e + 7d8da56 commit 217f81c
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 3 deletions.
47 changes: 47 additions & 0 deletions __tests__/unit/choreography.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { ChoreographyDict, IChoreography } from '../../src';

function checkChoreography(choreography: IChoreography, toBe: {choreographyName: string, transactionsLength: number}){
it("exists", () => {
expect(choreography).toBeDefined()
})

it("have proper name", () => {
expect(choreography.name).toBe(toBe.choreographyName)
})

it("have expected steps", () => {
expect(choreography.transactions.length).toBe(toBe.transactionsLength)
})
}

describe('choreography exists', () => {

describe("DISCORD_UPDATE_CHANNELS", () => {

checkChoreography(ChoreographyDict.DISCORD_UPDATE_CHANNELS, {
choreographyName: "DISCORD_UPDATE_CHANNELS",
transactionsLength: 2
})

})

describe("DISCORD_SCHEDULED_JOB", () => {

checkChoreography(ChoreographyDict.DISCORD_SCHEDULED_JOB, {
choreographyName: "DISCORD_SCHEDULED_JOB",
transactionsLength: 1
})

})

describe("DISCORD_FETCH_MEMBERS", () => {

checkChoreography(ChoreographyDict.DISCORD_FETCH_MEMBERS, {
choreographyName: "DISCORD_FETCH_MEMBERS",
transactionsLength: 1
})

})

})

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@togethercrew.dev/tc-messagebroker",
"version": "0.0.38",
"version": "0.0.39",
"description": "a service that include common things that need in every microservies ",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions src/enums/event.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const ServerEvent = {
const DiscordBotEvent = {
...BotEvent,
SEND_MESSAGE: 'SEND_MESSAGE',
FETCH_MEMBERS: 'FETCH_MEMBERS',
};

const DiscordAnalyzerEvent = {
Expand Down
10 changes: 8 additions & 2 deletions src/saga/choreography.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IChoreography } from '../interfaces/choreography.interface';
import { DISCORD_SCHEDULED_JOB_TRANSACTIONS, DISCORD_UPDATE_CHANNELS_TRANSACTIONS } from './transaction';
import { DISCORD_FETCH_MEMBERS_TRANSACTIONS, DISCORD_SCHEDULED_JOB_TRANSACTIONS, DISCORD_UPDATE_CHANNELS_TRANSACTIONS } from './transaction';

/* define the DISCORD_UPDATE_CHANNELS choreography */
const DISCORD_UPDATE_CHANNELS: IChoreography = {
Expand All @@ -13,8 +13,14 @@ const DISCORD_SCHEDULED_JOB: IChoreography = {
transactions: DISCORD_SCHEDULED_JOB_TRANSACTIONS,
};

const DISCORD_FETCH_MEMBERS: IChoreography = {
name: 'DISCORD_FETCH_MEMBERS',
transactions: DISCORD_FETCH_MEMBERS_TRANSACTIONS
}

/* all available Choreographies, will grow overtime */
export const ChoreographyDict = {
DISCORD_UPDATE_CHANNELS,
DISCORD_SCHEDULED_JOB
DISCORD_SCHEDULED_JOB,
DISCORD_FETCH_MEMBERS
} as const;
10 changes: 10 additions & 0 deletions src/saga/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,13 @@ export const DISCORD_SCHEDULED_JOB_TRANSACTIONS: ITransaction[] = [
...DEFAULT_TRANSACTION_PROPERTY,
},
];

export const DISCORD_FETCH_MEMBERS_TRANSACTIONS: ITransaction[] = [
{
queue: Queue.DISCORD_BOT,
event: Event.DISCORD_BOT.FETCH_MEMBERS,
order: 1,
status: Status.NOT_STARTED,
...DEFAULT_TRANSACTION_PROPERTY,
},
]

0 comments on commit 217f81c

Please sign in to comment.