Skip to content

Commit b8911a8

Browse files
committed
tests: generate tmpdir store for ollama pull testcase
Two reasons to do so: 1. The directory is cleaned up on test completed; 2. The hardcoded directory may not be available for write to the current process (because some other process is running the test suite in parallel, or because someone chmod -rwx the directory for some reason). In which case the test case fails with: PermissionError: [Errno 13] Permission denied: '/tmp/ramalama/store' This failure was triggered in nixpkgs CI: https://hydra.nixos.org/build/305125672 Signed-off-by: Ihar Hrachyshka <[email protected]>
1 parent eca00b1 commit b8911a8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

test/unit/test_ollama.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import tempfile
12
from unittest.mock import patch
23

34
import pytest
@@ -14,7 +15,9 @@ def ollama_model(args: StoreArgs):
1415

1516
@pytest.fixture
1617
def args():
17-
return StoreArgs(store="/tmp/ramalama/store", engine="podman", container=True)
18+
# create temporary store dir
19+
with tempfile.TemporaryDirectory() as tmpdir:
20+
yield StoreArgs(store=tmpdir, engine="podman", container=True)
1821

1922

2023
def test_ollama_model_initialization(ollama_model):

0 commit comments

Comments
 (0)