flow
This commit is contained in:
32
tests/test_platform.py
Normal file
32
tests/test_platform.py
Normal file
@@ -0,0 +1,32 @@
|
||||
"""Tests for flow.core.platform."""
|
||||
|
||||
import platform as _platform
|
||||
|
||||
import pytest
|
||||
|
||||
from flow.core.platform import PlatformInfo, detect_container_runtime, detect_platform
|
||||
|
||||
|
||||
def test_detect_platform_returns_platforminfo():
|
||||
info = detect_platform()
|
||||
assert isinstance(info, PlatformInfo)
|
||||
assert info.os in ("linux", "macos")
|
||||
assert info.arch in ("amd64", "arm64")
|
||||
assert info.platform == f"{info.os}-{info.arch}"
|
||||
|
||||
|
||||
def test_detect_platform_unsupported_os(monkeypatch):
|
||||
monkeypatch.setattr(_platform, "system", lambda: "FreeBSD")
|
||||
with pytest.raises(RuntimeError, match="Unsupported operating system"):
|
||||
detect_platform()
|
||||
|
||||
|
||||
def test_detect_platform_unsupported_arch(monkeypatch):
|
||||
monkeypatch.setattr(_platform, "machine", lambda: "mips")
|
||||
with pytest.raises(RuntimeError, match="Unsupported architecture"):
|
||||
detect_platform()
|
||||
|
||||
|
||||
def test_detect_container_runtime_returns_string_or_none():
|
||||
result = detect_container_runtime()
|
||||
assert result is None or result in ("docker", "podman")
|
||||
Reference in New Issue
Block a user