Skip to content

Commit

Permalink
add unit test and workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ori-n committed Feb 5, 2025
1 parent 74963e8 commit 8d66919
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Run Unit Tests
on: [push, workflow_dispatch]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Update Python
uses: actions/setup-python@v3
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests
run: |
source venv/bin/activate
pytest test/create_layer_unit_test.py
16 changes: 16 additions & 0 deletions test/create_layer_unit_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import pytest
from create_layer import _get_platform, _format_size

def test_get_platform():
assert _get_platform("arm64") == "manylinux2014_aarch64"
assert _get_platform("x86_64") == "manylinux2014_x86_64"
with pytest.raises(ValueError, match="Unknown architecture: unknown"):
_get_platform("unknown")

def test_format_size():
assert _format_size(500) == "500.00 B"
assert _format_size(1024) == "1.00 KiB"
assert _format_size(1048576) == "1.00 MiB"
assert _format_size(1073741824) == "1.00 GiB"
assert _format_size(1099511627776) == "1.00 TiB"
assert _format_size(1125899906842624) == "1.00 PiB"

0 comments on commit 8d66919

Please sign in to comment.