Skip to content

Commit

Permalink
fix(tests): define BUCKET_NAME in global setup
Browse files Browse the repository at this point in the history
  • Loading branch information
eoinsha committed Oct 26, 2023
1 parent 25489f2 commit 7eee745
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { sdkStreamMixin } from '@aws-sdk/util-stream-node'
import { S3Client, PutObjectCommand, GetObjectCommand } from '@aws-sdk/client-s3'
import { mockedContext } from '../../../mock-utils/lambda-context'
import { test, expect, vi } from 'vitest'
process.env.BUCKET_NAME = 'test-bucket'

import * as app from '../../app'
import * as transcode from '../../transcode'

Expand Down
2 changes: 1 addition & 1 deletion transcript-orchestration/functions/lib/envs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface Environment {
* This eliminates the need to check the existence of each environment variable where it is used.
*/
const envProxy: Environment = new Proxy({}, {
get(target: Record<string, string>, name: string): string {
get(_target: Record<string, string>, name: string): string {
const value = process.env[name]
if (!value) {
throw new Error(`Environment variable ${name} is not set`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { test, expect } from 'vitest'
import { handleEvent, S3KeysEvent } from '../../app'

process.env.BUCKET_NAME = 'test-bucket'

const testState: { options?: S3KeysEvent } = {}

test('constructs keys from audio input key', async (t) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { test, assert } from 'vitest'
import { VocabularySubstitutions } from '../../vocabulary'
import { MergedTranscript } from '../../types'

process.env.BUCKET_NAME = 'test-bucket'
import { handleEvent } from '../../app'

const mockS3 = mockClient(S3Client)
Expand Down
3 changes: 3 additions & 0 deletions transcript-orchestration/tests/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function setup () {
process.env.BUCKET_NAME = 'test-bucket'
}
3 changes: 3 additions & 0 deletions transcript-orchestration/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { defineConfig, defaultExclude } from 'vitest/config'

export default defineConfig({
test: {
globalSetup: [
'./tests/setup.ts'
],
coverage: {
reporter: ['text', 'html', 'lcov'],
exclude: [
Expand Down

0 comments on commit 7eee745

Please sign in to comment.