Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
fix(e2e): pass in AWS SDK instances
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Oct 27, 2020
1 parent d2a62a7 commit 7270732
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
18 changes: 15 additions & 3 deletions feature-runner/run-features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
WorkGroupName,
} from '../historicalData/settings'
import { athenaStepRunners } from './steps/athena'
import { STS, CloudFormation } from 'aws-sdk'
import { STS, CloudFormation, Iot, Athena } from 'aws-sdk'
import { v4 } from 'uuid'
import { region } from '../cdk/regions'
import {
Expand Down Expand Up @@ -148,9 +148,21 @@ program
},
}),
)
.addStepRunners(athenaStepRunners(world))
.addStepRunners(
athenaStepRunners({
...world,
athena: new Athena({
region,
}),
}),
)
.addStepRunners(bifravstStepRunners(world))
.addStepRunners(firmwareCIStepRunners(world))
.addStepRunners(
firmwareCIStepRunners({
...world,
iot: new Iot({ region }),
}),
)
.addStepRunners(storageStepRunners())
.addStepRunners(
randomStepRunners({
Expand Down
7 changes: 2 additions & 5 deletions feature-runner/steps/athena.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,18 @@ import { query, parseResult } from '@bifravst/athena-helpers'
import { Athena } from 'aws-sdk'

export const athenaStepRunners = ({
region,
historicaldataWorkgroupName,
athena,
}: {
region: string
historicaldataWorkgroupName: string
athena: Athena
}): ((step: InterpolatedStep) => StepRunnerFunc<BifravstWorld> | false)[] => [
regexMatcher<BifravstWorld>(
/^I run this query in the Athena workgroup ([^ ]+)$/,
)(async (_, step, runner) => {
if (step.interpolatedArgument === undefined) {
throw new Error('Must provide argument!')
}
const athena = new Athena({
region,
})
const q = query({
WorkGroup: historicaldataWorkgroupName,
athena,
Expand Down
9 changes: 5 additions & 4 deletions feature-runner/steps/firmwareCI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@ import {
} from '@bifravst/e2e-bdd-test-runner'
import { BifravstWorld } from '../run-features'
import { createDevice } from '../../cli/firmware-ci/createDevice'
import { Iot } from 'aws-sdk'
import { region } from '../../cdk/regions'
import { deleteDevice } from '../../cli/firmware-ci/deleteDevice'
import { Iot } from 'aws-sdk'

export const firmwareCIStepRunners = ({
mqttEndpoint,
certsDir,
iot,
}: {
certsDir: string
mqttEndpoint: string
iot: Iot
}): ((step: InterpolatedStep) => StepRunnerFunc<BifravstWorld> | false)[] => {
return [
regexMatcher<BifravstWorld>(/^I create a firmware CI device as "([^"]+)"$/)(
async ([storageName], __, runner) => {
const { thingName, thingArn } = await createDevice({
endpoint: mqttEndpoint,
certsDir,
iot: new Iot({ region }),
iot,
thingGroupName: runner.world['firmwareCI:thingGroupName'],
})
runner.store[`${storageName}:name`] = thingName
Expand All @@ -35,7 +36,7 @@ export const firmwareCIStepRunners = ({
return deleteDevice({
thingName: runner.store[`${storageName}:name`],
certsDir,
iot: new Iot({ region }),
iot,
thingGroupName: runner.world['firmwareCI:thingGroupName'],
})
},
Expand Down

0 comments on commit 7270732

Please sign in to comment.