Skip to content

Commit

Permalink
Fix broken build
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-harvey-z3q committed Jun 9, 2024
1 parent 3dca864 commit 4c9577f
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions tests/test_cdk_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,20 @@ def fake_subprocess_run(self, command, *, env, shell, stdout, check, cwd):
self.assertTrue(shell)
self.assertTrue(check)
self.assertIs(sys.stderr, stdout)
parser = argparse.ArgumentParser(prog="npx", exit_on_error=False)
parser = argparse.ArgumentParser(prog="npx")

if command.startswith("npx cdk-assets"):
if self.raise_assets_error:
raise subprocess.CalledProcessError(1, "bad command")
self.subprocess_envs["assets"] = env
parser.add_argument("--path")
parsed, _ = parser.parse_known_args(command.split(" "))
self.assertTrue(Path(parsed.path).exists())
try:
parsed, _ = parser.parse_known_args(command.split(" "))
self.assertTrue(Path(parsed.path).exists())
except SystemExit:
raise subprocess.CalledProcessError(1, "bad command")
self.artifacts_published = True

elif command.startswith("npx cdk synth"):
if self.raise_synth_error:
raise subprocess.CalledProcessError(1, "bad command")
Expand All @@ -298,19 +303,26 @@ def fake_subprocess_run(self, command, *, env, shell, stdout, check, cwd):
parser.add_argument("stack_logical_id")
parser.add_argument("-o", "--output")
parser.add_argument("--context", action="append")
parsed, _ = parser.parse_known_args(command.split(" "))
self.synth_context = {
key: value
for key, value in [context.split("=") for context in parsed.context]
}
assets_file = Path(parsed.output, f"{parsed.stack_logical_id}.assets.json")
template_file = Path(
parsed.output, f"{parsed.stack_logical_id}.template.json"
)
self.fs.create_file(str(assets_file), contents=json.dumps(self.manifest))
self.fs.create_file(
str(template_file), contents=json.dumps(self.expected_template)
)
try:
parsed, _ = parser.parse_known_args(command.split(" "))
self.synth_context = {
key: value
for key, value in [context.split("=") for context in parsed.context]
}
assets_file = Path(
parsed.output, f"{parsed.stack_logical_id}.assets.json"
)
template_file = Path(
parsed.output, f"{parsed.stack_logical_id}.template.json"
)
self.fs.create_file(
str(assets_file), contents=json.dumps(self.manifest)
)
self.fs.create_file(
str(template_file), contents=json.dumps(self.expected_template)
)
except SystemExit:
raise subprocess.CalledProcessError(1, "bad command")

def test_build_template__sceptre_user_data_specified__logs_warning(self):
self.builder.build_template(self.context, self.sceptre_user_data)
Expand Down

0 comments on commit 4c9577f

Please sign in to comment.