-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
39 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
async def run(hub, subcommand: str, target: str = "*", *args): | ||
with hub.test.container.roster() as rf: | ||
command = f"{hub.lib.sys.executable} -m soluble -R {rf} {subcommand} '{target}' {' '.join(args)}" | ||
|
||
# Run the command asynchronously | ||
process = await hub.lib.asyncio.create_subprocess_shell( | ||
command, | ||
stdout=hub.lib.asyncio.subprocess.PIPE, | ||
stderr=hub.lib.asyncio.subprocess.PIPE, | ||
) | ||
|
||
# Capture the stdout and stderr | ||
stdout, stderr = await process.communicate() | ||
|
||
# Decode the output | ||
stdout = stdout.decode() | ||
stderr = stderr.decode() | ||
|
||
# Assert the process was successful | ||
assert ( | ||
process.returncode == 0 | ||
), f"Command failed with code {process.returncode}: {stderr}" | ||
|
||
# Return the captured stdout | ||
return stdout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
from unittest import mock | ||
|
||
|
||
def test_cli(hub): | ||
def test_help(hub): | ||
with mock.patch("sys.argv", ["soluble"]): | ||
hub.soluble.init.cli() | ||
|
||
|
||
async def test_cli(hub): | ||
await hub.test.container.create() | ||
assert await hub.test.cmd.run("init") |