2022-11-14 11:05:24 -05:00
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { describe , it , expect , vi } from "vitest" ;
import { makeValidatePythonScriptStep } from "../scenarios/basic/steps/validate-python-script.js" ;
describe ( "validate-python-script" , ( ) => {
2024-04-30 16:36:13 -04:00
it ( "should throw an error if the script is not found" , ( ) => {
const s3ListObjects = vi . fn ( ( ) =>
Promise . resolve ( {
Contents : [ { Key : "WrongKey" } ] ,
} ) ,
) ;
2022-11-14 11:05:24 -05:00
const actions = { s3ListObjects } ;
const step = makeValidatePythonScriptStep ( actions ) ;
return expect ( step ( { } ) ) . rejects . toEqual (
new Error (
2024-04-30 16:36:13 -04:00
"Missing ETL python script. Did you run the setup steps in the readme?" ,
) ,
2022-11-14 11:05:24 -05:00
) ;
} ) ;
it ( "should return a context object" , async ( ) => {
process . env . PYTHON _SCRIPT _KEY = "scriptName" ;
2024-04-30 16:36:13 -04:00
const s3ListObjects = vi . fn ( ( ) =>
Promise . resolve ( {
Contents : [ { Key : "scriptName" } ] ,
} ) ,
) ;
2022-11-14 11:05:24 -05:00
const actions = { s3ListObjects } ;
const step = makeValidatePythonScriptStep ( actions ) ;
const actual = await step ( { } ) ;
expect ( actual ) . toEqual ( { } ) ;
} ) ;
} ) ;