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 authored and sergiusens committed Mar 14, 2024
1 parent 385cb8a commit c8e131e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions tests/unit/services/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ def test_write_metadata(
build_plan=default_build_plan,
)

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

package_service.write_metadata(prime_dir)

meta_dir = new_dir / "meta"
assert (meta_dir / "snap.yaml").read_text() == dedent(
"""\
name: default
Expand All @@ -148,7 +150,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 @@ -166,13 +168,16 @@ def test_write_metadata_with_manifest(
build_plan=default_build_plan,
)

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

package_service.write_metadata(prime_dir)

snap_yaml = yaml.safe_load((new_dir / "meta" / "snap.yaml").read_text())
snap_yaml = yaml.safe_load((meta_dir / "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 c8e131e

Please sign in to comment.