Complete rewrite of all core modules with proper abstractions:
- FlowError hierarchy with PlanConflict and ExecutionError
- Pure template substitution ($VAR, ${VAR}, {{expr}})
- XDG path constants
- Frozen PlatformInfo dataclass with context detection
- Console with color/quiet/TTY support
- Runtime primitives (CommandRunner, FileSystem, GitClient, SystemRuntime)
- Config loading with target parsing and manifest merging
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
"""Tests for flow.core.platform."""
|
|
|
|
import os
|
|
|
|
import pytest
|
|
|
|
from flow.core.platform import PlatformInfo, detect_context, detect_platform
|
|
|
|
|
|
def test_platform_info_computes_platform_string():
|
|
p = PlatformInfo(os="linux", arch="x64")
|
|
assert p.platform == "linux-x64"
|
|
|
|
|
|
def test_detect_platform_returns_valid_info():
|
|
info = detect_platform()
|
|
assert info.os in ("linux", "macos")
|
|
assert info.arch in ("x64", "arm64")
|
|
assert info.platform == f"{info.os}-{info.arch}"
|
|
|
|
|
|
def test_detect_platform_raises_flow_error_on_unsupported(monkeypatch):
|
|
from flow.core.errors import FlowError
|
|
monkeypatch.setattr("platform.system", lambda: "FreeBSD")
|
|
with pytest.raises(FlowError, match="Unsupported operating system"):
|
|
detect_platform()
|
|
|
|
|
|
def test_detect_context_host(monkeypatch):
|
|
monkeypatch.delenv("DF_NAMESPACE", raising=False)
|
|
monkeypatch.delenv("DF_PLATFORM", raising=False)
|
|
assert detect_context() == "host"
|
|
|
|
|
|
def test_detect_context_vm(monkeypatch):
|
|
monkeypatch.setenv("DF_NAMESPACE", "personal")
|
|
monkeypatch.setenv("DF_PLATFORM", "orb")
|
|
assert detect_context() == "vm"
|