Skip to content

Commit

Permalink
Add end-to-end smoke tests
Browse files Browse the repository at this point in the history
  • Loading branch information
westphahl committed Jan 29, 2020
1 parent ea6c17d commit d7c4286
Show file tree
Hide file tree
Showing 29 changed files with 213 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/e2e/.konverter-vault-test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
wf74SQKHyZigGSevWnQKPxBtfCP8BdukG0yKPYi9vOs=
30 changes: 30 additions & 0 deletions tests/e2e/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import pytest

from click.testing import CliRunner
from ruamel.yaml import YAML

from konverter.__main__ import cli


def pytest_collect_file(parent, path):
if path.ext == ".yaml" and path.basename.startswith("test_"):
return E2ETest(path.basename, path, parent)


class E2ETest(pytest.Item):
def __init__(self, name, fspath, parent):
super().__init__(name, parent)
self.fspath = fspath
*_, identifier = str(fspath.basename).partition("_")
self.expect_path = f"{fspath.dirname}/expect_{identifier}"

def runtest(self):
runner = CliRunner()
result = runner.invoke(cli, [str(self.fspath)])
assert result.exit_code == 0, result.output
with open(self.expect_path) as expect_file:
assert result.output == expect_file.read()

@property
def nodeid(self):
return f"e2e::{self.fspath.basename}"
10 changes: 10 additions & 0 deletions tests/e2e/expect_basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
variable: Hello World!
VARIABLE: HELLO WORLD!
b64_variable: SGVsbG8gV29ybGQh
json_variable: '{"number": 42, "other": "FOOBAR"}'

template: |-
Hello World!
42
12 changes: 12 additions & 0 deletions tests/e2e/expect_contexts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
variable: Hello World!
VARIABLE: HELLO WORLD!
b64_variable: SGVsbG8gV29ybGQh
json_variable: '{"number": 43, "other": "BARFOO"}'

template: |-
Hello World!
43
Hello context!
11 changes: 11 additions & 0 deletions tests/e2e/expect_dir.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
json_variable: '{"number": 42, "other": "FOOBAR"}'

template: |-
Hello World!
42
---
variable: Hello World!
VARIABLE: HELLO WORLD!
b64_variable: SGVsbG8gV29ybGQh
11 changes: 11 additions & 0 deletions tests/e2e/expect_dir_and_file.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
json_variable: '{"number": 42, "other": "FOOBAR"}'

template: |-
Hello World!
42
---
variable: Hello World!
VARIABLE: HELLO WORLD!
b64_variable: SGVsbG8gV29ybGQh
3 changes: 3 additions & 0 deletions tests/e2e/expect_encrypted.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
encrypted_value: Hello Secret!
unencrypted_value: Hello unencryted secret!
11 changes: 11 additions & 0 deletions tests/e2e/expect_multidoc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
variable: Hello World!
VARIABLE: HELLO WORLD!
b64_variable: SGVsbG8gV29ybGQh
---
json_variable: '{"number": 42, "other": "FOOBAR"}'

template: |-
Hello World!
42
11 changes: 11 additions & 0 deletions tests/e2e/expect_multifile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
variable: Hello World!
VARIABLE: HELLO WORLD!
b64_variable: SGVsbG8gV29ybGQh
---
json_variable: '{"number": 42, "other": "FOOBAR"}'

template: |-
Hello World!
42
9 changes: 9 additions & 0 deletions tests/e2e/templates/basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
variable: !k/expr foobar
VARIABLE: !k/expr foobar|upper
b64_variable: !k/expr foobar|b64encode
json_variable: !k/expr object|to_json

template: !k/template |-
{{ foobar }}
{{ object.number }}
11 changes: 11 additions & 0 deletions tests/e2e/templates/contexts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
variable: !k/expr foobar
VARIABLE: !k/expr foobar|upper
b64_variable: !k/expr foobar|b64encode
json_variable: !k/expr object|to_json

template: !k/template |-
{{ foobar }}
{{ object.number }}
{{ barfoo }}
6 changes: 6 additions & 0 deletions tests/e2e/templates/dir/one.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
json_variable: !k/expr object|to_json

template: !k/template |-
{{ foobar }}
{{ object.number }}
3 changes: 3 additions & 0 deletions tests/e2e/templates/dir/two.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
variable: !k/expr foobar
VARIABLE: !k/expr foobar|upper
b64_variable: !k/expr foobar|b64encode
6 changes: 6 additions & 0 deletions tests/e2e/templates/dir_and_file/dir/one.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
json_variable: !k/expr object|to_json

template: !k/template |-
{{ foobar }}
{{ object.number }}
3 changes: 3 additions & 0 deletions tests/e2e/templates/dir_and_file/two.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
variable: !k/expr foobar
VARIABLE: !k/expr foobar|upper
b64_variable: !k/expr foobar|b64encode
2 changes: 2 additions & 0 deletions tests/e2e/templates/encrypted.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
encrypted_value: !k/expr encrypted_foobar
unencrypted_value: !k/expr unencrypted_barfoo
10 changes: 10 additions & 0 deletions tests/e2e/templates/multidoc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
variable: !k/expr foobar
VARIABLE: !k/expr foobar|upper
b64_variable: !k/expr foobar|b64encode
---
json_variable: !k/expr object|to_json

template: !k/template |-
{{ foobar }}
{{ object.number }}
3 changes: 3 additions & 0 deletions tests/e2e/templates/multifile/one.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
variable: !k/expr foobar
VARIABLE: !k/expr foobar|upper
b64_variable: !k/expr foobar|b64encode
6 changes: 6 additions & 0 deletions tests/e2e/templates/multifile/two.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
json_variable: !k/expr object|to_json

template: !k/template |-
{{ foobar }}
{{ object.number }}
5 changes: 5 additions & 0 deletions tests/e2e/test_basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
templates:
- templates/basic.yaml

context:
- vars/_generic.yaml
6 changes: 6 additions & 0 deletions tests/e2e/test_contexts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
templates:
- templates/contexts.yaml

context:
- vars/contexts.yaml
- vars/_generic.yaml
5 changes: 5 additions & 0 deletions tests/e2e/test_dir.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
templates:
- templates/dir

context:
- vars/_generic.yaml
6 changes: 6 additions & 0 deletions tests/e2e/test_dir_and_file.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
templates:
- templates/dir_and_file/dir
- templates/dir_and_file/two.yaml

context:
- vars/_generic.yaml
9 changes: 9 additions & 0 deletions tests/e2e/test_encrypted.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
templates:
- templates/encrypted.yaml

providers:
default:
key_path: .konverter-vault-test

context:
- vars/_encrypted.yaml
5 changes: 5 additions & 0 deletions tests/e2e/test_multidoc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
templates:
- templates/multidoc.yaml

context:
- vars/_generic.yaml
6 changes: 6 additions & 0 deletions tests/e2e/test_multifile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
templates:
- templates/multifile/one.yaml
- templates/multifile/two.yaml

context:
- vars/_generic.yaml
2 changes: 2 additions & 0 deletions tests/e2e/vars/_encrypted.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
encrypted_foobar: !k/vault gAAAAABeMdtcuKywSJfQo4b0fFDX0PC3ZGoKWGr3cRgl64bjx8taTlV-jAxlcX9AW3x2E5bx5OkYhQbvW8TRUcnxqtefneNirA==
unencrypted_barfoo: !k/encrypt Hello unencryted secret!
5 changes: 5 additions & 0 deletions tests/e2e/vars/_generic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
foobar: Hello World!

object:
number: 42
other: FOOBAR
5 changes: 5 additions & 0 deletions tests/e2e/vars/contexts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
object:
number: 43
other: BARFOO

barfoo: Hello context!

0 comments on commit d7c4286

Please sign in to comment.