Merge pull request #74 from yannh/add-regression-tests-openapi2jsonschema

Add regression tests openapi2jsonschema
This commit is contained in:
Yann Hamon 2021-09-26 13:51:08 +02:00 committed by GitHub
commit 72d648a5d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 11981 additions and 2 deletions

View file

@ -1,7 +1,7 @@
name: ci
on: push
jobs:
test:
kubeconform-test:
runs-on: ubuntu-latest
steps:
- name: checkout
@ -16,9 +16,21 @@ jobs:
- name: acceptance-test
run: make docker-acceptance
openapi2jsonschema-test:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: acceptance-test
working-directory: ./scripts
run: make docker-acceptance
goreleaser:
runs-on: ubuntu-latest
needs: test
needs:
- kubeconform-test
- openapi2jsonschema-test
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: checkout

6
scripts/Dockerfile.bats Normal file
View file

@ -0,0 +1,6 @@
FROM python:3.9.7-alpine3.14
RUN apk --no-cache add bats
COPY acceptance.bats openapi2jsonschema.py requirements.txt /code/
COPY fixtures /code/fixtures
WORKDIR /code
RUN pip install -r requirements.txt

9
scripts/Makefile Normal file
View file

@ -0,0 +1,9 @@
#!/usr/bin/make -f
# This is really early days
build-python-bats:
docker build -t python-bats -f Dockerfile.bats .
docker-acceptance: build-python-bats
docker run --entrypoint "/usr/bin/bats" -t python-bats /code/acceptance.bats

9
scripts/acceptance.bats Normal file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env bats
@test "Should generate expected prometheus resource" {
run ./openapi2jsonschema.py fixtures/prometheus-operator-0prometheusCustomResourceDefinition.yaml
[ "$status" -eq 0 ]
[ "$output" = "JSON schema written to prometheus_v1.json" ]
run diff prometheus_v1.json ./fixtures/prometheus_v1-expected.json
[ "$status" -eq 0 ]
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

1
scripts/requirements.txt Normal file
View file

@ -0,0 +1 @@
pyyaml