Skip to content

Commit

Permalink
fix: ensure pact dir exists
Browse files Browse the repository at this point in the history
Signed-off-by: JP-Ellis <[email protected]>
  • Loading branch information
JP-Ellis committed Nov 8, 2024
1 parent 10ac966 commit 0f6b594
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/pact/message_pact.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import json
import os
from pathlib import Path
from subprocess import Popen
import warnings

Expand Down Expand Up @@ -97,7 +98,7 @@ def __init__(

self.consumer = consumer
self.file_write_mode = file_write_mode
self.pact_dir = pact_dir or os.getcwd()
self.pact_dir = Path(pact_dir or os.getcwd()).resolve()
self.provider = provider
self.publish_to_broker = publish_to_broker
self.version = version
Expand Down Expand Up @@ -176,11 +177,16 @@ def write_to_pact_file(self):
:rtype: int
"""
if not self.pact_dir.exists():
self.pact_dir.mkdir(parents=True)

Check warning on line 181 in src/pact/message_pact.py

View check run for this annotation

Codecov / codecov/patch

src/pact/message_pact.py#L181

Added line #L181 was not covered by tests
elif not self.pact_dir.is_dir():
raise NotADirectoryError(f"{self.pact_dir} is not a directory")

Check warning on line 183 in src/pact/message_pact.py

View check run for this annotation

Codecov / codecov/patch

src/pact/message_pact.py#L183

Added line #L183 was not covered by tests

command = [
MESSAGE_PATH,
"update",
json.dumps(self._messages[0]),
"--pact-dir", self.pact_dir,
"--pact-dir", str(self.pact_dir),
f"--pact-specification-version={self.version}",
"--consumer", f"{self.consumer.name}",
"--provider", f"{self.provider.name}",
Expand Down

0 comments on commit 0f6b594

Please sign in to comment.