Add initial tests
This commit is contained in:
parent
26da85487f
commit
a0dbb79d30
3 changed files with 41 additions and 1 deletions
|
@ -24,7 +24,7 @@ def devops_config(overrides: dict) -> dict:
|
||||||
"k3s_letsencrypt_endpoint": "k3s_letsencrypt_endpoint",
|
"k3s_letsencrypt_endpoint": "k3s_letsencrypt_endpoint",
|
||||||
"k3s_enable_echo": "false",
|
"k3s_enable_echo": "false",
|
||||||
"k3s_app_filename_to_provision": "k3s_app.yaml",
|
"k3s_app_filename_to_provision": "k3s_app.yaml",
|
||||||
"tf_provider_types": ["DIGITALOCEAN", "HETZNER", "AWS"],
|
"tf_provider_types": ["DIGITALOCEAN", "HETZNER", "AWS", "TERRAFORM_BACKEND_GIT"],
|
||||||
"tf_additional_vars": [],
|
"tf_additional_vars": [],
|
||||||
"tf_output_json_name": "the_out.json",
|
"tf_output_json_name": "the_out.json",
|
||||||
"tf_use_workspace": None,
|
"tf_use_workspace": None,
|
||||||
|
@ -58,6 +58,11 @@ def devops_config(overrides: dict) -> dict:
|
||||||
"release_artifact_server_url": None,
|
"release_artifact_server_url": None,
|
||||||
"release_organisation": None,
|
"release_organisation": None,
|
||||||
"release_repository_name": None,
|
"release_repository_name": None,
|
||||||
|
"git_backend_repo": "https://repo.example.com/meissa/infra-states",
|
||||||
|
"git_backend_ref": "main",
|
||||||
|
"git_backend_state": "test.json",
|
||||||
|
"git_backend_username": "tf_backend_user",
|
||||||
|
"git_backend_token": "324asd234df435sfdgh",
|
||||||
"credentials_mappings": [
|
"credentials_mappings": [
|
||||||
{
|
{
|
||||||
"gopass_path": "a/path",
|
"gopass_path": "a/path",
|
||||||
|
|
30
src/test/python/domain/test_provider_tf_backend_git.py
Normal file
30
src/test/python/domain/test_provider_tf_backend_git.py
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
from pybuilder.core import Project
|
||||||
|
from pathlib import Path
|
||||||
|
from src.main.python.ddadevops.domain import (
|
||||||
|
BuildType,
|
||||||
|
TerraformBackendGit,
|
||||||
|
)
|
||||||
|
from .helper import devops_config
|
||||||
|
|
||||||
|
def test_tf_backend_git_creation():
|
||||||
|
sut = TerraformBackendGit(
|
||||||
|
{
|
||||||
|
"module": "module",
|
||||||
|
"stage": "test",
|
||||||
|
"git_backend_repo": "https://repo.example.com/meissa/infra-states",
|
||||||
|
"git_backend_ref": "main",
|
||||||
|
"git_backend_state": "test.json",
|
||||||
|
"git_backend_username": "tf_backend_user",
|
||||||
|
"git_backend_token": "324asd234df435sfdgh",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
assert sut is not None
|
||||||
|
assert sut.is_valid()
|
||||||
|
|
||||||
|
def test_should_calculate_backend_config():
|
||||||
|
sut = TerraformBackendGit(devops_config({}))
|
||||||
|
assert {
|
||||||
|
"address": "http://localhost:6061/?type=git&repository=https://repo.example.com/meissa/infra-states&ref=main&state=test/module/test.json",
|
||||||
|
"lock_address": "http://localhost:6061/?type=git&repository=https://repo.example.com/meissa/infra-states&ref=main&state=test/module/test.json",
|
||||||
|
"unlock_address": "http://localhost:6061/?type=git&repository=https://repo.example.com/meissa/infra-states&ref=main&state=test/module/test.json",
|
||||||
|
} == sut.backend_config()
|
|
@ -17,6 +17,7 @@ def test_creation():
|
||||||
assert sut.providers[ProviderType.DIGITALOCEAN]
|
assert sut.providers[ProviderType.DIGITALOCEAN]
|
||||||
assert sut.providers[ProviderType.HETZNER]
|
assert sut.providers[ProviderType.HETZNER]
|
||||||
assert sut.providers[ProviderType.AWS]
|
assert sut.providers[ProviderType.AWS]
|
||||||
|
assert sut.providers[ProviderType.TERRAFORM_BACKEND_GIT]
|
||||||
|
|
||||||
|
|
||||||
def test_should_calculate_output_json_name():
|
def test_should_calculate_output_json_name():
|
||||||
|
@ -188,3 +189,7 @@ def test_should_calculate_local_state_handling():
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
assert not sut.is_local_state()
|
assert not sut.is_local_state()
|
||||||
|
|
||||||
|
def test_should_use_backend_git():
|
||||||
|
sut = TerraformDomain(devops_config({}))
|
||||||
|
assert TerraformDomain.uses_backend_git()
|
Loading…
Reference in a new issue