Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit test for packer build #19

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Unit Tests"

on:
- push
- pull_request

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- run: tox

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var/
*.egg-info/
.installed.cfg
*.egg
*.eggs/

# Installer logs
pip-log.txt
Expand Down
21 changes: 21 additions & 0 deletions tests/docker.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
packer {
required_plugins {
docker = {
version = ">= 0.0.7"
source = "github.com/hashicorp/docker"
}
}
}

source "docker" "ubuntu" {
image = "ubuntu:xenial"
commit = true
}

build {
name = "python-packer"
sources = [
"source.docker.ubuntu"
]
}

26 changes: 24 additions & 2 deletions tests/test_packer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,50 @@
from packer import Installer

class TestPacker(unittest.TestCase):
test_template = './tests/docker.pkr.hcl'
packer = Packer(template=test_template)

@classmethod
def setUpClass(self):
self.packer.init('tests')

@unittest.skip("Already used for setup")
def test_init(self):
self.assertEqual("TODO", "FIXME")
self.packer.init('tests')
pass

def test_build(self):
self.assertEqual("TODO", "FIXME")
build_output = self.packer.build(parallel=False, debug=True, force=False)
build_success = build_output.find("artifacts of successful builds")
self.assertGreater(build_success, 0)

def test_fix(self):
self.assertEqual("TODO", "FIXME")

def test_inspect(self):
self.assertEqual("TODO", "FIXME")

def test_push(self):
self.assertEqual("TODO", "FIXME")

def test_validate(self):
self.assertEqual("TODO", "FIXME")

def test_version(self):
self.assertEqual("TODO", "FIXME")

def test_add_opt(self):
self.assertEqual("TODO", "FIXME")

def test_validate_argtype(self):
self.assertEqual("TODO", "FIXME")

def test_append_base_arguments(self):
self.assertEqual("TODO", "FIXME")

def test_join_comma(self):
self.assertEqual("TODO", "FIXME")

def test_parse_inspection_output(self):
self.assertEqual("TODO", "FIXME")

Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ deps =
-rdev-requirements.txt
commands =
pytest
setenv =
HOME = /tmp

[testenv:flake8]
deps =
Expand Down
Loading