Skip to content

Commit

Permalink
fix(test): use prime dir in some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
syu-w committed Mar 14, 2024
1 parent b601c77 commit 4fb0323
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/unit/services/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ def test_write_metadata(
build_plan=default_build_plan,
)

package_service.write_metadata(new_dir)
prime_dir = new_dir / "prime"

package_service.write_metadata(prime_dir)

meta_dir = new_dir / "meta"
meta_dir = prime_dir / "meta"
assert (meta_dir / "snap.yaml").read_text() == dedent(
"""\
name: default
Expand All @@ -144,7 +146,7 @@ def test_write_metadata(
"""
)

assert not (new_dir / "snap" / "manifest.yaml").exists()
assert not (prime_dir / "snap" / "manifest.yaml").exists()


def test_write_metadata_with_manifest(
Expand All @@ -162,13 +164,15 @@ def test_write_metadata_with_manifest(
build_plan=default_build_plan,
)

package_service.write_metadata(new_dir)
prime_dir = new_dir / "prime"

package_service.write_metadata(prime_dir)

snap_yaml = yaml.safe_load((new_dir / "meta" / "snap.yaml").read_text())
snap_yaml = yaml.safe_load((prime_dir / "meta" / "snap.yaml").read_text())

# This will be different every time due to started_at differing, we can check
# that it's a valid manifest and compare some fields to snap.yaml.
manifest_dict = yaml.safe_load((new_dir / "snap" / "manifest.yaml").read_text())
manifest_dict = yaml.safe_load((prime_dir / "snap" / "manifest.yaml").read_text())
manifest = models.Manifest.parse_obj(manifest_dict)

assert manifest.snapcraft_version == __version__
Expand Down

0 comments on commit 4fb0323

Please sign in to comment.