Skip to content

Commit

Permalink
Add run interfaces to demo plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
DSoko2 committed May 10, 2024
1 parent 058a33d commit dea3584
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
26 changes: 25 additions & 1 deletion proti-plugins-demo/src/demo-generator-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ import {
type Generator,
type GeneratorPlugin,
type PluginInitFn,
type PluginPostRunFn,
type PluginPreRunFn,
type PluginShutdownFn,
type PluginWithInitFn,
type PluginWithPostRunFn,
type PluginWithPreRunFn,
type PluginWithShutdownFn,
type ResourceArgs,
type ResourceOutput,
Expand Down Expand Up @@ -36,7 +40,12 @@ export class DemoGenerator extends TraceGenerator {
*/
export class DemoGeneratorPlugin
extends fc.Arbitrary<Generator>
implements GeneratorPlugin, PluginWithInitFn, PluginWithShutdownFn
implements
GeneratorPlugin,
PluginWithInitFn,
PluginWithPreRunFn,
PluginWithPostRunFn,
PluginWithShutdownFn
{
private static generatorIdCounter: number = 0;

Expand Down Expand Up @@ -68,6 +77,21 @@ export class DemoGeneratorPlugin
// eslint-disable-next-line class-methods-use-this
readonly init: PluginInitFn = async () => {};

/**
* Optional pre test run method called right before a test run starts.
* Enforced through optional implementation of {@link PluginWithPreRunFn}.
*/
// eslint-disable-next-line class-methods-use-this
readonly preRun: PluginPreRunFn = async () => {};

/**
* Optional post test run method called right after a test run ended with
* its results and the values the IaC program exported. Enforced through
* optional implementation of {@link PluginWithPostRunFn}.
*/
// eslint-disable-next-line class-methods-use-this
readonly postRun: PluginPostRunFn = async () => {};

/**
* Optional shutdown method called after the ProTI check terminated.
* Enforced through optional implementation of {@link PluginWithShutdownFn}.
Expand Down
26 changes: 25 additions & 1 deletion proti-plugins-demo/src/demo-oracle-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ import type {
ResourceArgs,
ResourceOracle,
PluginInitFn,
PluginPostRunFn,
PluginPreRunFn,
PluginShutdownFn,
PluginWithInitFn,
PluginWithPostRunFn,
PluginWithPreRunFn,
PluginWithShutdownFn,
TestResult,
} from '@proti-iac/core';
Expand All @@ -13,7 +17,12 @@ import { config } from './config';
* Simple {@link OraclePlugin} checking that all resource URNs are unique.
*/
export class DemoOraclePlugin
implements ResourceOracle<Set<string>>, PluginWithInitFn, PluginWithShutdownFn
implements
ResourceOracle<Set<string>>,
PluginWithInitFn,
PluginWithPreRunFn,
PluginWithPostRunFn,
PluginWithShutdownFn
{
readonly name = 'Demo Oracle';

Expand Down Expand Up @@ -41,6 +50,21 @@ export class DemoOraclePlugin
// eslint-disable-next-line class-methods-use-this
readonly init: PluginInitFn = async () => {};

/**
* Optional pre test run method called right before a test run starts.
* Enforced through optional implementation of {@link PluginWithPreRunFn}.
*/
// eslint-disable-next-line class-methods-use-this
readonly preRun: PluginPreRunFn = async () => {};

/**
* Optional post test run method called right after a test run ended with
* its results and the values the IaC program exported. Enforced through
* optional implementation of {@link PluginWithPostRunFn}.
*/
// eslint-disable-next-line class-methods-use-this
readonly postRun: PluginPostRunFn = async () => {};

/**
* Optional shutdown method called after the ProTI check terminated.
* Enforced through optional implementation of {@link PluginWithShutdownFn}.
Expand Down

0 comments on commit dea3584

Please sign in to comment.