Skip to content

Commit 7be38f6

Browse files
committed
fix nt specific test failures
Signed-off-by: Drew Cain <groksrc@gmail.com>
1 parent 7c2cf3c commit 7be38f6

5 files changed

Lines changed: 31 additions & 10 deletions

File tree

.github/workflows/test.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ on:
1414

1515
jobs:
1616
test:
17-
runs-on: ubuntu-latest
1817
strategy:
1918
fail-fast: false
2019
matrix:
20+
os: [ubuntu-latest, windows-latest]
2121
python-version: [ "3.12" ]
22+
runs-on: ${{ matrix.os }}
2223

2324
steps:
2425
- uses: actions/checkout@v4
@@ -35,10 +36,21 @@ jobs:
3536
run: |
3637
pip install uv
3738
38-
- name: Install just
39+
- name: Install just (Linux/macOS)
40+
if: runner.os != 'Windows'
3941
run: |
4042
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/local/bin
4143
44+
- name: Install just (Windows)
45+
if: runner.os == 'Windows'
46+
run: |
47+
# Download and install just for Windows
48+
$url = "https://github.com/casey/just/releases/latest/download/just-x86_64-pc-windows-msvc.zip"
49+
Invoke-WebRequest -Uri $url -OutFile just.zip
50+
Expand-Archive just.zip -DestinationPath .
51+
Move-Item just.exe C:\Windows\System32\
52+
shell: powershell
53+
4254
- name: Create virtual env
4355
run: |
4456
uv venv
@@ -54,4 +66,4 @@ jobs:
5466
- name: Run tests
5567
run: |
5668
uv pip install pytest pytest-cov
57-
just test
69+
just test

tests/cli/test_project_commands.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ def test_project_default_command(mock_reload, mock_run, cli_env):
8585
# Patching call_put directly since it's imported at the module level
8686

8787
# Patch the os.environ for checking
88-
with patch.dict(os.environ, {}, clear=True):
88+
# On Windows, preserve USERPROFILE to allow home directory detection
89+
env_vars = {}
90+
if os.name == 'nt' and 'USERPROFILE' in os.environ:
91+
env_vars['USERPROFILE'] = os.environ['USERPROFILE']
92+
93+
with patch.dict(os.environ, env_vars, clear=True):
8994
# Patch ConfigManager.set_default_project to prevent validation error
9095
with patch("basic_memory.config.ConfigManager.set_default_project"):
9196
runner = CliRunner()

tests/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from textwrap import dedent
77
from typing import AsyncGenerator
88

9+
import os
910
import pytest
1011
import pytest_asyncio
1112
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, async_sessionmaker
@@ -51,6 +52,9 @@ def project_root() -> Path:
5152
def config_home(tmp_path, monkeypatch) -> Path:
5253
# Patch HOME environment variable for the duration of the test
5354
monkeypatch.setenv("HOME", str(tmp_path))
55+
# On Windows, also set USERPROFILE
56+
if os.name == 'nt':
57+
monkeypatch.setenv("USERPROFILE", str(tmp_path))
5458
# Set BASIC_MEMORY_HOME to the test directory
5559
monkeypatch.setenv("BASIC_MEMORY_HOME", str(tmp_path / "basic-memory"))
5660
return tmp_path

tests/sync/test_tmp_files.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ async def test_rapid_atomic_writes(watch_service, project_config, test_project,
122122
await create_test_file(tmp2_path, "Second version")
123123

124124
# Simulate the first atomic write
125-
tmp1_path.rename(final_path)
125+
tmp1_path.replace(final_path)
126126

127127
# Brief pause to ensure file system registers the change
128128
await asyncio.sleep(0.1)
@@ -132,7 +132,7 @@ async def test_rapid_atomic_writes(watch_service, project_config, test_project,
132132
assert content1 == "First version"
133133

134134
# Simulate the second atomic write
135-
tmp2_path.rename(final_path)
135+
tmp2_path.replace(final_path)
136136

137137
# Verify content was updated
138138
content2 = final_path.read_text(encoding="utf-8")

tests/test_config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Test configuration management."""
22

33
from basic_memory.config import BasicMemoryConfig
4-
4+
from pathlib import Path
55

66
class TestBasicMemoryConfig:
77
"""Test BasicMemoryConfig behavior with BASIC_MEMORY_HOME environment variable."""
@@ -15,7 +15,7 @@ def test_default_behavior_without_basic_memory_home(self, config_home, monkeypat
1515

1616
# Should use the default path (home/basic-memory)
1717
expected_path = (config_home / "basic-memory").as_posix()
18-
assert config.projects["main"] == expected_path
18+
assert config.projects["main"] == Path(expected_path).as_posix()
1919

2020
def test_respects_basic_memory_home_environment_variable(self, config_home, monkeypatch):
2121
"""Test that config respects BASIC_MEMORY_HOME environment variable."""
@@ -38,7 +38,7 @@ def test_model_post_init_respects_basic_memory_home(self, config_home, monkeypat
3838

3939
# model_post_init should have added main project with BASIC_MEMORY_HOME
4040
assert "main" in config.projects
41-
assert config.projects["main"] == custom_path
41+
assert config.projects["main"] == Path(custom_path).as_posix()
4242

4343
def test_model_post_init_fallback_without_basic_memory_home(self, config_home, monkeypatch):
4444
"""Test that model_post_init falls back to default when BASIC_MEMORY_HOME is not set."""
@@ -52,7 +52,7 @@ def test_model_post_init_fallback_without_basic_memory_home(self, config_home, m
5252
# model_post_init should have added main project with default path
5353
expected_path = (config_home / "basic-memory").as_posix()
5454
assert "main" in config.projects
55-
assert config.projects["main"] == expected_path
55+
assert config.projects["main"] == Path(expected_path).as_posix()
5656

5757
def test_basic_memory_home_with_relative_path(self, config_home, monkeypatch):
5858
"""Test that BASIC_MEMORY_HOME works with relative paths."""

0 commit comments

Comments
 (0)