Skip to content

Commit

Permalink
test: add proper test pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
BPR02 committed Nov 21, 2024
1 parent f13ec64 commit dd086fc
Show file tree
Hide file tree
Showing 8 changed files with 308 additions and 117 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ __pycache__/

### Poetry ###
dist/

### Beet ###
.out
7 changes: 7 additions & 0 deletions examples/sanity_test/beet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data_pack:
load: src
overlays:
- formats:
min_inclusive: 48
max_inclusive: 48
directory: overlay_48
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
say I'm here now
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
say I was here first
348 changes: 231 additions & 117 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ isort = "^5.10.1"
python-semantic-release = "^9.14.0"
pyright = "^1.1.389"
twine = "^5.1.1"
lectern = "^0.34.0"
pytest-insta = "^0.3.0"

[tool.semantic_release]
branch = "main"
Expand Down
47 changes: 47 additions & 0 deletions tests/snapshots/examples__build_sanity_test__0.pack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Lectern snapshot

## Data pack

`@data_pack pack.mcmeta`

```json
{
"pack": {
"pack_format": 48,
"description": ""
},
"overlays": {
"entries": [
{
"formats": {
"min_inclusive": 48,
"max_inclusive": 48
},
"directory": "overlay_48"
}
]
}
}
```

### demo

`@function demo:demo`

```mcfunction
say I'm here now
```

## Overlay `overlay_48`

`@overlay overlay_48`

### demo

`@function demo:demo`

```mcfunction
say I was here first
```

`@endoverlay`
16 changes: 16 additions & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os
from pathlib import Path

import pytest
from beet import ProjectCache, run_beet
from lectern import Document
from pytest_insta import SnapshotFixture


@pytest.mark.parametrize("directory", os.listdir("examples"))
def test_build(snapshot: SnapshotFixture, directory: str, tmp_path: Path):
with run_beet(
directory=f"examples/{directory}",
cache=ProjectCache(tmp_path / ".beet_cache", tmp_path / "generated"),
) as ctx:
assert snapshot("pack.md") == ctx.inject(Document)

0 comments on commit dd086fc

Please sign in to comment.