Skip to content

Commit

Permalink
fix: fix issue of goal command interacting with filename containing d…
Browse files Browse the repository at this point in the history
…ot (#424)

* fix: fixed issue with filename containing dot

* fix: make the regex simpler
  • Loading branch information
negar-abbasi authored Feb 19, 2024
1 parent 40765e7 commit 22ece81
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/algokit/core/goal.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def get_volume_mount_path_local(directory_name: str) -> Path:
return get_app_config_dir().joinpath(directory_name, "goal_mount")


filename_pattern = re.compile(r"^[\w-]+\.\w+$")
filename_pattern = re.compile(r"^[\w\-\.]+\.\w+$")


def is_path_or_filename(argument: str) -> bool:
Expand Down
45 changes: 45 additions & 0 deletions tests/goal/test_goal.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,3 +523,48 @@ def test_goal_simple_args_on_named_localnet(proc_mock: ProcMock, app_dir_mock: A

assert result.exit_code == 0
verify(_normalize_output(result.output.replace(str(app_dir_mock.app_config_dir), "{app_config}")))


@pytest.mark.usefixtures(
"mocked_goal_mount_path",
"_setup_input_files",
"_setup_latest_dummy_compose",
"_mock_proc_with_running_localnet",
"_mock_proc_with_algod_running_state",
)
@pytest.mark.parametrize(
"_setup_input_files", [[{"name": "contract.approval.teal", "content": DUMMY_CONTRACT_TEAL}]], indirect=True
)
def test_goal_simple_args_with_input_output_files_with_dot_convention_name(
proc_mock: ProcMock,
cwd: Path,
app_dir_mock: AppDirs,
) -> None:
expected_arguments = [
"docker",
"exec",
"--interactive",
"--workdir",
"/root",
"algokit_sandbox_algod",
"goal",
"clerk",
"compile",
]

proc_mock.set_output(
expected_arguments, output=["File compiled"], side_effect=dump_file, side_effect_args={"cwd": cwd}
)

result = invoke("goal clerk compile contract.approval.teal -o approval.compiled", cwd=cwd)

# Check if the paths in command have changed in preprocess step
assert _normalize_output(proc_mock.called[3].command[9]) == "/root/goal_mount/contract.approval.teal"
assert _normalize_output(proc_mock.called[3].command[11]) == "/root/goal_mount/approval.compiled"

# Check for the result status
assert result.exit_code == 0

# Check if the output file is created and copied in cwd in postprocess step
assert (cwd / "approval.compiled").exists()
verify(_normalize_output(result.output.replace(str(app_dir_mock.app_config_dir), "{app_config}")))
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DEBUG: Running 'docker version' in '{current_working_directory}'
DEBUG: docker: STDOUT
DEBUG: docker: STDERR
DEBUG: Running 'docker compose ls --format json --filter name=algokit_sandbox*' in '{current_working_directory}'
DEBUG: docker: []
DEBUG: Running 'docker compose ps algod --format json' in '{app_config}/sandbox'
DEBUG: docker: [{"Name": "algokit_sandbox_algod", "State": "running"}]
DEBUG: Running 'docker exec --interactive --workdir /root algokit_sandbox_algod goal clerk compile /root/goal_mount/contract.approval.teal -o /root/goal_mount/approval.compiled' in '{current_working_directory}'
File compiled

1 comment on commit 22ece81

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/algokit
   __init__.py15753%6–13, 17–24, 32–34
   __main__.py440%1–7
src/algokit/cli
   completions.py108298%83, 98
   deploy.py72790%44, 46, 92–94, 158, 182
   dispenser.py121199%77
   doctor.py48394%142–144
   explore.py501276%34–39, 41–46
   generate.py67396%74–75, 140
   goal.py44198%71
   init.py1951692%284–285, 335, 338–340, 351, 395, 421, 461, 470–472, 475–480, 493
   localnet.py1191587%74–78, 111, 123, 138–148, 161, 206, 227–228
   task.py34391%25–28
src/algokit/cli/common
   utils.py26292%120, 123
src/algokit/cli/tasks
   analyze.py81199%81
   assets.py821384%65–66, 72, 74–75, 105, 119, 125–126, 132, 134, 136–137
   ipfs.py51884%52, 80, 92, 94–95, 105–107
   mint.py66494%48, 70, 91, 250
   send_transaction.py651085%52–53, 57, 89, 158, 170–174
   sign_transaction.py59886%21, 28–30, 71–72, 109, 123
   transfer.py39392%26, 90, 117
   utils.py994555%26–34, 40–43, 75–76, 100–101, 125–133, 152–162, 209, 258–259, 279–290, 297–299
   vanity_address.py561082%41, 45–48, 112, 114, 121–123
   wallet.py79495%21, 66, 136, 162
src/algokit/core
   bootstrap.py1171091%101–102, 124, 151, 180–185
   conf.py54885%12, 24, 28, 36, 38, 71–73
   deploy.py691184%61–64, 73–75, 79, 84, 91–93
   dispenser.py2022687%91, 123–124, 141–149, 191–192, 198–200, 218–219, 259–260, 318, 332–334, 345–346, 356, 369, 384
   doctor.py65789%67–69, 92–94, 134
   generate.py48394%44, 81, 99
   goal.py60395%30–31, 41
   log_handlers.py68790%50–51, 63, 112–116, 125
   proc.py45198%98
   sandbox.py2181892%62, 73–75, 96, 142–149, 160, 456, 472, 497, 505
   typed_client_generation.py80594%55–57, 70, 75
   utils.py1043170%44–45, 49–68, 129, 132, 138–152
   version_prompt.py72889%26–27, 39, 58–61, 79, 108
src/algokit/core/tasks
   analyze.py93397%105–112, 187
   ipfs.py63789%58–64, 140, 144, 146, 152
   nfd.py491373%25, 31, 34–41, 70–72, 99–101
   vanity_address.py903462%49–50, 54, 59–75, 92–108, 128–131
   wallet.py71593%37, 129, 155–157
src/algokit/core/tasks/mint
   mint.py781087%123–133, 187
   models.py901188%50, 52, 57, 71–74, 85–88
TOTAL348640388% 

Tests Skipped Failures Errors Time
403 0 💤 0 ❌ 0 🔥 22.824s ⏱️

Please sign in to comment.