Skip to content

Commit

Permalink
Log about the charm path used and raise if multiple paths found
Browse files Browse the repository at this point in the history
  • Loading branch information
Deezzir committed Nov 22, 2024
1 parent edd1c0a commit 5f10c88
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/functional/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
import os
import platform
from pathlib import Path

Expand Down Expand Up @@ -152,11 +151,19 @@ def required_resources(resources: list[Resource], provided_collectors: set) -> l

@pytest.fixture()
def charm_path(base: str, architecture: str) -> Path:
"""Fixture to determine the charm path based on the base."""
"""Fixture to determine the charm path based on the base and architecture."""
glob_path = f"hardware-observer_*{base.replace('@', '-')}-{architecture}*.charm"
paths = list(Path(".").glob(glob_path))

if not paths:
raise FileNotFoundError(f"The path for the charm for {base}-{architecture} is not found.")

return os.getcwd() / paths[0]
if len(paths) > 1:
raise FileNotFoundError(
f"Multiple charms found for {base}-{architecture}. Please provide only one."
)

# The bundle will need the full path to the charm
path = paths[0].absolute()
log.info(f"Using charm path: {path}")
return path

0 comments on commit 5f10c88

Please sign in to comment.