This repository has been archived by the owner on Apr 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
519061f
commit 488f888
Showing
4 changed files
with
85 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import os | ||
from harbor.test import BaseHarborTestClass | ||
from harbor.tasks.deployment import UpdateFilesTask | ||
|
||
|
||
class UpdateFilesTaskTest(BaseHarborTestClass): | ||
def test_functional_validates_deployment_yml_file_not_created(self): | ||
"""Test that deployment.yml/deployment.yaml needs to be created first and the message for the end user is clear | ||
""" | ||
|
||
out = self.execute_task(UpdateFilesTask(), args={'--ask-vault-pass': False, '--vault-passwords': ''}, env={}) | ||
self.assertIn('Deployment not configured - missing deployment.yml or deployment.yaml file', out) | ||
|
||
def test_functional_structure_is_copied(self): | ||
"""Verify that the structure is copied, and the files are rendered using JINJA2""" | ||
|
||
# prepare configuration | ||
self.prepare_valid_deployment_yml() | ||
task = UpdateFilesTask() | ||
|
||
# mock external dependencies: github.com and ansible-galaxy | ||
task.download_roles = lambda *args, **kwargs: None | ||
|
||
with self.subTest('Verify overall task exit code'): | ||
out = self.execute_task(task, args={'--ask-vault-pass': False, '--vault-passwords': ''}, env={}) | ||
self.assertIn('TASK_EXIT_RESULT=True', out) | ||
|
||
with self.subTest('Verify copied files'): | ||
# check a few files, including files that are rendered from JINJA2 like inventory and playbook | ||
for filename in ['ansible.cfg', 'Vagrantfile', 'harbor.inventory.cfg', 'harbor.playbook.yml']: | ||
self.assertTrue(os.path.isfile(self.get_test_env_subdirectory('.rkd/deployment') + '/' + filename)) | ||
|
||
with self.subTest('Check if JINJA2 templates are rendered'): | ||
with open(self.get_test_env_subdirectory('.rkd/deployment') + '/harbor.inventory.cfg', 'r') as f: | ||
# vagrant is a default value from file created by self.prepare_valid_deployment_yml() | ||
self.assertIn('ansible_ssh_user=docker', f.read()) |