flow
This commit is contained in:
59
tests/test_commands.py
Normal file
59
tests/test_commands.py
Normal file
@@ -0,0 +1,59 @@
|
||||
"""Tests for command modules — registration and target parsing."""
|
||||
|
||||
from flow.commands.enter import _parse_target
|
||||
from flow.commands.container import _cname, _parse_image_ref
|
||||
|
||||
|
||||
class TestParseTarget:
|
||||
def test_full_target(self):
|
||||
user, ns, plat = _parse_target("root@personal@orb")
|
||||
assert user == "root"
|
||||
assert ns == "personal"
|
||||
assert plat == "orb"
|
||||
|
||||
def test_no_user(self):
|
||||
user, ns, plat = _parse_target("personal@orb")
|
||||
assert user is None
|
||||
assert ns == "personal"
|
||||
assert plat == "orb"
|
||||
|
||||
def test_namespace_only(self):
|
||||
user, ns, plat = _parse_target("personal")
|
||||
assert user is None
|
||||
assert ns == "personal"
|
||||
assert plat is None
|
||||
|
||||
|
||||
class TestCname:
|
||||
def test_adds_prefix(self):
|
||||
assert _cname("api") == "dev-api"
|
||||
|
||||
def test_no_double_prefix(self):
|
||||
assert _cname("dev-api") == "dev-api"
|
||||
|
||||
|
||||
class TestParseImageRef:
|
||||
def test_simple_image(self):
|
||||
ref, repo, tag, label = _parse_image_ref("node")
|
||||
assert ref == "registry.tomastm.com/node:latest"
|
||||
assert tag == "latest"
|
||||
|
||||
def test_tm0_shorthand(self):
|
||||
ref, repo, tag, label = _parse_image_ref("tm0/node")
|
||||
assert "registry.tomastm.com" in ref
|
||||
assert "node" in ref
|
||||
|
||||
def test_docker_shorthand(self):
|
||||
ref, repo, tag, label = _parse_image_ref("docker/python")
|
||||
assert "docker.io" in ref
|
||||
assert "python" in ref
|
||||
|
||||
def test_with_tag(self):
|
||||
ref, repo, tag, label = _parse_image_ref("node:20")
|
||||
assert tag == "20"
|
||||
assert ":20" in ref
|
||||
|
||||
def test_full_registry(self):
|
||||
ref, repo, tag, label = _parse_image_ref("ghcr.io/user/image:v1")
|
||||
assert ref == "ghcr.io/user/image:v1"
|
||||
assert tag == "v1"
|
||||
Reference in New Issue
Block a user