forked from Hostea/dashboard
feat: infrastructure tests: check if commits are pushed to remote
parent
8640fcf449
commit
3318ca8da2
|
@ -17,6 +17,7 @@ import shutil
|
|||
|
||||
from django.test import TestCase, Client, override_settings
|
||||
from django.conf import settings
|
||||
from git import Repo
|
||||
|
||||
from dash.models import Instance
|
||||
from .utils import Infra
|
||||
|
@ -80,6 +81,7 @@ class InfraUtilTest(TestCase):
|
|||
def test_add_vm(self):
|
||||
infra = Infra()
|
||||
c = Client()
|
||||
conf = settings.HOSTEA["INFRA"]["HOSTEA_REPO"]
|
||||
login_util(self, c, "accounts.home")
|
||||
subdomain = "add_vm"
|
||||
|
||||
|
@ -89,7 +91,23 @@ class InfraUtilTest(TestCase):
|
|||
t=self, c=c, instance_name=subdomain, config=self.instance_config[0]
|
||||
)
|
||||
|
||||
before_add = infra.repo.head.commit.hexsha
|
||||
instance = Instance.objects.get(name=subdomain)
|
||||
woodpecker_agent_secret = infra.add_vm(instance=instance)
|
||||
after_add = infra.repo.head.commit.hexsha
|
||||
self.assertEqual(before_add is not after_add, True)
|
||||
|
||||
c = custom_config(test_name="test_add_vm--get-head")
|
||||
path = c["INFRA"]["HOSTEA_REPO"]["PATH"]
|
||||
repo = Repo.clone_from(
|
||||
conf["REMOTE"], path, env={"GIT_SSH_COMMAND": infra.ssh_cmd}
|
||||
)
|
||||
self.assertEqual(repo.head.commit.hexsha == after_add, True)
|
||||
|
||||
before_rm = infra.repo.head.commit.hexsha
|
||||
infra.remove_vm(instance=instance)
|
||||
after_rm = infra.repo.head.commit.hexsha
|
||||
self.assertEqual(before_add is not after_add, True)
|
||||
|
||||
repo.git.pull()
|
||||
self.assertEqual(repo.head.commit.hexsha == after_rm, True)
|
||||
|
|
Loading…
Reference in New Issue