Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
guyzsarun committed Aug 9, 2023
1 parent cf93c3c commit 374f6c8
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,28 @@ jobs:
file: docker/Dockerfile.test
build-contexts: |
base_img=docker-image://${{ env.BASE_TAG }}
test-json:
name: Test JSON Conversion
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v2

- uses: docker/setup-buildx-action@v2
with:
driver: docker

- name: Build Test Docker image
uses: docker/build-push-action@v4
with:
context: .
file: docker/Dockerfile.test
tags: user/xrootd-cmstfc:test
build-contexts: |
base_img=docker-image://${{ env.BASE_TAG }}
- name: Unit test
run: |
docker run --rm user/xrootd-cmstfc:test python3 -m pytest -v
23 changes: 23 additions & 0 deletions tests/test_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pytest
import subprocess

json_file = "file:/xrootd/tests/storage.json?volume={}&protocol={}"
test_data =[
("/store/temp/test","TEST_JSON","root","/store/test"),
("/store/temp/test","TEST_JSON","prefix","root://cern-vm//cms/store/temp/test"),
("/test/mc/file0","CMSSST_TEST","root","root://host.domain/aaa/bbb//test/mc/file0"),
("/other/mc/file1","CMSSST_TEST","root","root://host.domain/aaa/bbb//store/nomc/file1/trailer"),
("/other/mc/file2","CMSSST_TEST","root","root://host.domain/aaa/bbb//store/nomc/file2/trailer"),
("store/mc/file3","CMSSST_TEST","root","root://host.domain/aaa/bbb/never/first/xmc/file3/trailer"),
("other/mc/file4","CMSSST_TEST","root","root://host.domain/aaa/bbb/other/xmc/file4"),
("/store/data/file5","CMSSST_TEST","root","root://host.domain/aaa/bbb//store/first/data/file5/trailer")
]

@pytest.mark.parametrize("lfn,volume,protocol,pfn", test_data)
def test_json(lfn,volume,protocol,pfn):
output = subprocess.check_output([
"./build/test_json.o", lfn, json_file.format(volume,protocol)],encoding='utf-8')

assert pfn == output.strip()


0 comments on commit 374f6c8

Please sign in to comment.