-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Azure provider unit tests (#382)
- Loading branch information
Showing
14 changed files
with
2,162 additions
and
556 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
packages/framework-provider-azure-infrastructure/src/infrastructure/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/framework-provider-azure/test/helpers/event-helper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { EventEnvelope } from '@boostercloud/framework-types' | ||
import { random, date } from 'faker' | ||
import { Context, ExecutionContext, Logger as AzureLogger, TraceContext } from '@azure/functions' | ||
|
||
export function createMockEventEnvelopes(numOfEvents = 1): Array<EventEnvelope> { | ||
return new Array(numOfEvents).fill( | ||
{ | ||
version: random.number(), | ||
entityID: random.uuid(), | ||
kind: 'event', | ||
value: { | ||
id: random.uuid(), | ||
}, | ||
typeName: random.word(), | ||
entityTypeName: random.word(), | ||
requestID: random.uuid(), | ||
createdAt: date.past().toISOString(), | ||
}, | ||
0, | ||
numOfEvents | ||
) | ||
} | ||
|
||
export function addMockSystemGeneratedProperties(eventEnvelopes: Array<EventEnvelope>): Array<EventEnvelope> { | ||
return eventEnvelopes.map((eventEnvelope: EventEnvelope) => { | ||
return { | ||
...eventEnvelope, | ||
id: random.uuid(), | ||
_rid: random.alphaNumeric(24), | ||
_self: `dbs/${random.alphaNumeric(8)}/colls/${random.alphaNumeric(12)}/docs/${random.alphaNumeric(24)}/`, | ||
_etag: `"${random.uuid()}"`, | ||
_attachments: 'attachments/', | ||
_ts: ~~(date.past().getTime() / 1000), | ||
} | ||
}) | ||
} | ||
|
||
export function wrapEventEnvelopesForCosmosDB(eventEnvelopes: Array<EventEnvelope>): Context { | ||
return { | ||
bindingData: {}, | ||
bindingDefinitions: [], | ||
executionContext: {} as ExecutionContext, | ||
invocationId: '', | ||
log: {} as AzureLogger, | ||
traceContext: {} as TraceContext, | ||
done(err?: Error | string | null, result?: any): void {}, | ||
bindings: { rawEvent: eventEnvelopes }, | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
packages/framework-provider-azure/test/helpers/read-model-helper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ReadModelInterface } from '@boostercloud/framework-types' | ||
import { random } from 'faker' | ||
|
||
export function createMockReadModel(): ReadModelInterface { | ||
return { | ||
id: random.uuid(), | ||
some: 'object', | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.