Skip to content

Commit

Permalink
Add Transform test
Browse files Browse the repository at this point in the history
  • Loading branch information
scorbiere committed Aug 9, 2024
1 parent 29c0732 commit ef8e3e6
Show file tree
Hide file tree
Showing 5 changed files with 1,329 additions and 3 deletions.
14 changes: 11 additions & 3 deletions bin/add_transform_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,14 @@ def get_input_file_path() -> Path:


def copy_input_file_to_transform_test_dir(input_file_path: Path, transform_test_input_path: Path) -> None:
shutil.copyfile(input_file_path, transform_test_input_path)
print(f"Transform Test input file generated {transform_test_input_path}")
try:
shutil.copyfile(input_file_path, transform_test_input_path)
print(f"Transform Test input file generated {transform_test_input_path}")
except shutil.SameFileError:
print(f"Source and destination are the same file: {input_file_path}")
except Exception as e:
raise e



def verify_input_template(input_file_path: Path) -> None:
Expand Down Expand Up @@ -99,7 +105,9 @@ def main() -> None:
verify_input_template(input_file_path)

transform_test_input_path = TRANSFORM_TEST_DIR / "input" / (file_basename + ".yaml")
copy_input_file_to_transform_test_dir(input_file_path, transform_test_input_path)
# check if the template is not already in the transform test input dir
if input_file_path != transform_test_input_path:
copy_input_file_to_transform_test_dir(input_file_path, transform_test_input_path)

generate_transform_test_output_files(transform_test_input_path, file_basename)

Expand Down
45 changes: 45 additions & 0 deletions tests/translator/input/state_machine_with_events_and_alias.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Transform: AWS::Serverless-2016-10-31
Resources:
MyStateMachine:
Type: AWS::Serverless::StateMachine
Properties:
Type: STANDARD
Definition:
StartAt: HelloWorld
States:
HelloWorld:
Type: Pass
Result: 1
End: true
Role: !Sub "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/doesNotExist"
AutoPublishAlias: test
UseAliasAsEventTarget: true
Events:
CWEvent:
Type: CloudWatchEvent
Properties:
Pattern:
detail:
state:
- terminated
EBEvent:
Type: EventBridgeRule
Properties:
Pattern:
source: [aws.tag]
ApiEvent:
Type: Api
Properties:
Path: /path
Method: get
CWSchedule:
Type: Schedule
Properties:
Schedule: rate(1 minute)
Name: TestSchedule
Description: test schedule
Enabled: false
ScheduleEvent:
Type: ScheduleV2
Properties:
ScheduleExpression: rate(1 minute)
Loading

0 comments on commit ef8e3e6

Please sign in to comment.