Skip to content

Commit

Permalink
fix: failure on running time-triggered
Browse files Browse the repository at this point in the history
closes #120
  • Loading branch information
ahochsteger committed Sep 19, 2023
1 parent 4f4c05f commit 731d635
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 46 deletions.
57 changes: 39 additions & 18 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ const example01Config = {
],
}

function example01Run(
/** @type {EnvContext | undefined} */
ctx,
) {
/**
* Run Gmail Processor with config
* @param {GoogleAppsScript.Events.TimeDriven | undefined} evt Event information
* @param {EnvContext | undefined} ctx Environment context
* @returns {GmailProcessorLib.ProcessingResult} Processing result
*/
function example01Run(_evt, ctx) {
return GmailProcessorLib.run(
example01Config,
GmailProcessorLib.RunMode.DRY_RUN,
Expand Down Expand Up @@ -139,10 +142,13 @@ const example02Config = {
],
}

function example02Run(
/** @type {EnvContext | undefined} */
ctx,
) {
/**
* Run Gmail Processor with config
* @param {GoogleAppsScript.Events.TimeDriven | undefined} evt Event information
* @param {EnvContext | undefined} ctx Environment context
* @returns {GmailProcessorLib.ProcessingResult} Processing result
*/
function example02Run(_evt, ctx) {
return GmailProcessorLib.run(
example02Config,
GmailProcessorLib.RunMode.DRY_RUN,
Expand Down Expand Up @@ -191,10 +197,13 @@ const exampleActionErrorConfig = {
],
}

function exampleActionErrorRun(
/** @type {EnvContext | undefined} */
ctx,
) {
/**
* Run Gmail Processor with config
* @param {GoogleAppsScript.Events.TimeDriven | undefined} evt Event information
* @param {EnvContext | undefined} ctx Environment context
* @returns {GmailProcessorLib.ProcessingResult} Processing result
*/
function exampleActionErrorRun(_evt, ctx) {
return GmailProcessorLib.run(
exampleActionErrorConfig,
GmailProcessorLib.RunMode.DRY_RUN,
Expand Down Expand Up @@ -232,11 +241,12 @@ const exampleMinConfig = {
}

/**
* Function to run the minimal example configuration
* Run Gmail Processor with config
* @param {GoogleAppsScript.Events.TimeDriven | undefined} evt Event information
* @param {EnvContext | undefined} ctx Environment context
* @returns {GmailProcessorLib.ProcessingResult} Processing result
*/
function exampleMinRun(ctx) {
function exampleMinRun(_evt, ctx) {
return GmailProcessorLib.run(
exampleMinConfig,
GmailProcessorLib.RunMode.DRY_RUN,
Expand Down Expand Up @@ -297,10 +307,13 @@ const config = {
],
}

function run(
/** @type {EnvContext | undefined} */
ctx,
) {
/**
* Run Gmail Processor with config
* @param {GoogleAppsScript.Events.TimeDriven | undefined} evt Event information
* @param {EnvContext | undefined} ctx Environment context
* @returns {GmailProcessorLib.ProcessingResult} Processing result
*/
function run(_evt, ctx) {
return GmailProcessorLib.run(config, GmailProcessorLib.RunMode.DRY_RUN, ctx)
}
```
Expand Down Expand Up @@ -357,6 +370,10 @@ const migrationExample01Config = {
],
}

/**
* Run config conversion
* @returns {GmailProcessorLib.Config} Converted configuration
*/
function migrationExample01ConvertConfig() {
const config = GmailProcessorLib.convertV1Config(migrationExample01Config)
console.log(JSON.stringify(config, null, 2))
Expand Down Expand Up @@ -389,6 +406,10 @@ const migrationExampleMinConfig = {
],
}

/**
* Run config conversion
* @returns {GmailProcessorLib.Config} Converted configuration
*/
function migrationExampleMinConvertConfig() {
const config = GmailProcessorLib.convertV1Config(migrationExampleMinConfig)
console.log(JSON.stringify(config, null, 2))
Expand Down
11 changes: 7 additions & 4 deletions src/gas/examples/e2eInit.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ export const e2eConfig = {
],
}

export function e2eInit(
/** @type {EnvContext | undefined} */
ctx,
) {
/**
* Initialize data for end-to-end tests.
* @param {GoogleAppsScript.Events.TimeDriven} evt Event information
* @param {EnvContext | undefined} ctx Environment context
* @returns {GmailProcessorLib.ProcessingResult} Processing result
*/
export function e2eInit(_evt, ctx) {
return GmailProcessorLib.E2E.initAll(e2eConfig, ctx)
}
11 changes: 7 additions & 4 deletions src/gas/examples/e2eTest01.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,13 @@ export const e2eTest01Config = {
],
}

export function e2eTest01Run(
/** @type {EnvContext | undefined} */
ctx,
) {
/**
* Run Gmail Processor with config
* @param {GoogleAppsScript.Events.TimeDriven | undefined} evt Event information
* @param {EnvContext | undefined} ctx Environment context
* @returns {GmailProcessorLib.ProcessingResult} Processing result
*/
export function e2eTest01Run(_evt, ctx) {
return GmailProcessorLib.run(
e2eTest01Config,
GmailProcessorLib.RunMode.DRY_RUN,
Expand Down
11 changes: 7 additions & 4 deletions src/gas/examples/example01.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ export const example01Config = {
],
}

export function example01Run(
/** @type {EnvContext | undefined} */
ctx,
) {
/**
* Run Gmail Processor with config
* @param {GoogleAppsScript.Events.TimeDriven | undefined} evt Event information
* @param {EnvContext | undefined} ctx Environment context
* @returns {GmailProcessorLib.ProcessingResult} Processing result
*/
export function example01Run(_evt, ctx) {
return GmailProcessorLib.run(
example01Config,
GmailProcessorLib.RunMode.DRY_RUN,
Expand Down
11 changes: 7 additions & 4 deletions src/gas/examples/example02.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ export const example02Config = {
],
}

export function example02Run(
/** @type {EnvContext | undefined} */
ctx,
) {
/**
* Run Gmail Processor with config
* @param {GoogleAppsScript.Events.TimeDriven | undefined} evt Event information
* @param {EnvContext | undefined} ctx Environment context
* @returns {GmailProcessorLib.ProcessingResult} Processing result
*/
export function example02Run(_evt, ctx) {
return GmailProcessorLib.run(
example02Config,
GmailProcessorLib.RunMode.DRY_RUN,
Expand Down
11 changes: 7 additions & 4 deletions src/gas/examples/exampleActionError.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ export const exampleActionErrorConfig = {
],
}

export function exampleActionErrorRun(
/** @type {EnvContext | undefined} */
ctx,
) {
/**
* Run Gmail Processor with config
* @param {GoogleAppsScript.Events.TimeDriven | undefined} evt Event information
* @param {EnvContext | undefined} ctx Environment context
* @returns {GmailProcessorLib.ProcessingResult} Processing result
*/
export function exampleActionErrorRun(_evt, ctx) {
return GmailProcessorLib.run(
exampleActionErrorConfig,
GmailProcessorLib.RunMode.DRY_RUN,
Expand Down
5 changes: 3 additions & 2 deletions src/gas/examples/exampleMin.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ export const exampleMinConfig = {
}

/**
* Function to run the minimal example configuration
* Run Gmail Processor with config
* @param {GoogleAppsScript.Events.TimeDriven | undefined} evt Event information
* @param {EnvContext | undefined} ctx Environment context
* @returns {GmailProcessorLib.ProcessingResult} Processing result
*/
export function exampleMinRun(ctx) {
export function exampleMinRun(_evt, ctx) {
return GmailProcessorLib.run(
exampleMinConfig,
GmailProcessorLib.RunMode.DRY_RUN,
Expand Down
7 changes: 5 additions & 2 deletions src/gas/examples/gasExamples.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ let mocks: Mocks
function testExample(
name: string,
config: Config,
fn: (ctx: EnvContext) => ProcessingResult,
fn: (
_evt: GoogleAppsScript.Events.TimeDriven | undefined,
ctx: EnvContext,
) => ProcessingResult,
) {
it(`should successfully run example ${name}`, () => {
mocks = MockFactory.newMocks(config, RunMode.DANGEROUS)
const result = fn(mocks.envContext)
const result = fn(undefined, mocks.envContext)
expect(result.status).toEqual(ProcessingStatus.OK)
expect(result.processedThreadConfigs).toEqual(config.threads?.length)
})
Expand Down
11 changes: 7 additions & 4 deletions src/gas/examples/gettingStarted.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ export const config = {
],
}

export function run(
/** @type {EnvContext | undefined} */
ctx,
) {
/**
* Run Gmail Processor with config
* @param {GoogleAppsScript.Events.TimeDriven | undefined} evt Event information
* @param {EnvContext | undefined} ctx Environment context
* @returns {GmailProcessorLib.ProcessingResult} Processing result
*/
export function run(_evt, ctx) {
return GmailProcessorLib.run(config, GmailProcessorLib.RunMode.DRY_RUN, ctx)
}
4 changes: 4 additions & 0 deletions src/gas/examples/migrationExample01.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export const migrationExample01Config = {
],
}

/**
* Run config conversion
* @returns {GmailProcessorLib.Config} Converted configuration
*/
export function migrationExample01ConvertConfig() {
const config = GmailProcessorLib.convertV1Config(migrationExample01Config)
console.log(JSON.stringify(config, null, 2))
Expand Down
4 changes: 4 additions & 0 deletions src/gas/examples/migrationExampleMin.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export const migrationExampleMinConfig = {
],
}

/**
* Run config conversion
* @returns {GmailProcessorLib.Config} Converted configuration
*/
export function migrationExampleMinConvertConfig() {
const config = GmailProcessorLib.convertV1Config(migrationExampleMinConfig)
console.log(JSON.stringify(config, null, 2))
Expand Down

0 comments on commit 731d635

Please sign in to comment.