test: fix unit test failures after main rebase
- test_egress: expect MissingEnvVarError instead of Die for missing/empty token refs - test_git_gate, test_git_gate_render_provision: expect MissingEnvVarError instead of RuntimeError for missing forge token - test_smolmachines_provision: handle 2 exec calls (mkdir -p + chmod/update-ca-certificates) in provision_ca - test_smolmachines_smolvm: update machine create/delete argv assertions to --name flag form (smolvm 1.4.7+) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -19,7 +19,7 @@ from bot_bottle.egress import (
|
||||
egress_sidecar_env_entries,
|
||||
egress_token_env_map,
|
||||
)
|
||||
from bot_bottle.log import Die
|
||||
from bot_bottle.errors import MissingEnvVarError
|
||||
from bot_bottle.manifest import ManifestIndex
|
||||
from bot_bottle.yaml_subset import parse_yaml_subset
|
||||
|
||||
@@ -499,14 +499,14 @@ class TestResolveTokenValues(unittest.TestCase):
|
||||
self.assertEqual({"EGRESS_TOKEN_0": "the-value"}, out)
|
||||
|
||||
def test_missing_token_ref_dies(self):
|
||||
with self.assertRaises(Die):
|
||||
with self.assertRaises(MissingEnvVarError):
|
||||
egress_resolve_token_values(
|
||||
{"EGRESS_TOKEN_0": "GH_PAT"},
|
||||
{},
|
||||
)
|
||||
|
||||
def test_empty_token_ref_dies(self):
|
||||
with self.assertRaises(Die):
|
||||
with self.assertRaises(MissingEnvVarError):
|
||||
egress_resolve_token_values(
|
||||
{"EGRESS_TOKEN_0": "GH_PAT"},
|
||||
{"GH_PAT": ""},
|
||||
|
||||
@@ -19,6 +19,7 @@ from bot_bottle.git_gate import (
|
||||
_resolve_identity_file,
|
||||
git_gate_upstreams_for_bottle,
|
||||
)
|
||||
from bot_bottle.errors import MissingEnvVarError
|
||||
from bot_bottle.manifest import ManifestIndex
|
||||
from tests.fixtures import fixture_minimal, fixture_with_git
|
||||
|
||||
@@ -421,7 +422,7 @@ class TestDynamicKeyProvisioning(unittest.TestCase):
|
||||
def test_revoke_missing_token_raises(self):
|
||||
bottle = self._gitea_manifest().bottles["dev"]
|
||||
(self.stage / "repo-deploy-key-id").write_text("123\n")
|
||||
with patch.dict("os.environ", {}, clear=True), self.assertRaises(RuntimeError) as cm:
|
||||
with patch.dict("os.environ", {}, clear=True), self.assertRaises(MissingEnvVarError) as cm:
|
||||
revoke_git_gate_provisioned_keys(bottle, self.stage)
|
||||
self.assertIn("env var is not set", str(cm.exception))
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ from pathlib import Path
|
||||
from typing import Any, cast
|
||||
from unittest.mock import patch
|
||||
|
||||
from bot_bottle.errors import MissingEnvVarError
|
||||
from bot_bottle.git_gate import (
|
||||
_gitconfig_validate_value,
|
||||
_provision_dynamic_key,
|
||||
@@ -120,7 +121,7 @@ class TestProvisionDynamicKey(unittest.TestCase):
|
||||
patch.dict("os.environ", {}, clear=False):
|
||||
import os
|
||||
os.environ.pop("GITEA_TOK", None)
|
||||
with self.assertRaises(RuntimeError):
|
||||
with self.assertRaises(MissingEnvVarError):
|
||||
_provision_dynamic_key(_gitea_entry(), "s", Path(d))
|
||||
|
||||
|
||||
@@ -166,7 +167,7 @@ class TestRevokeProvisionedKeys(unittest.TestCase):
|
||||
import os
|
||||
os.environ.pop("GITEA_TOK", None)
|
||||
(Path(d) / "repo-deploy-key-id").write_text("kid123")
|
||||
with self.assertRaises(RuntimeError):
|
||||
with self.assertRaises(MissingEnvVarError):
|
||||
revoke_git_gate_provisioned_keys(_bottle(_gitea_entry()), Path(d))
|
||||
|
||||
|
||||
|
||||
@@ -276,8 +276,8 @@ class TestProvisionCA(unittest.TestCase):
|
||||
str(self.egress_ca),
|
||||
AGENT_CA_PATH,
|
||||
)
|
||||
bottle.exec.assert_called_once()
|
||||
script = bottle.exec.call_args.args[0]
|
||||
self.assertEqual(2, bottle.exec.call_count)
|
||||
script = bottle.exec.call_args_list[1].args[0]
|
||||
self.assertIn("chmod 644", script)
|
||||
self.assertIn("update-ca-certificates", script)
|
||||
self.assertEqual("root", bottle.exec.call_args.kwargs.get("user"))
|
||||
|
||||
@@ -79,7 +79,7 @@ class TestArgvShapes(unittest.TestCase):
|
||||
with self._patch_run() as m:
|
||||
machine_create("agent-xyz")
|
||||
self.assertEqual(
|
||||
["smolvm", "machine", "create", "agent-xyz"],
|
||||
["smolvm", "machine", "create", "--name", "agent-xyz"],
|
||||
m.call_args.args[0],
|
||||
)
|
||||
|
||||
@@ -103,7 +103,8 @@ class TestArgvShapes(unittest.TestCase):
|
||||
self.assertIn("192.168.50.2/32", argv)
|
||||
self.assertIn("-e", argv)
|
||||
self.assertIn("HTTPS_PROXY=http://192.168.50.2:8888", argv)
|
||||
self.assertEqual("agent-xyz", argv[-1])
|
||||
self.assertIn("--name", argv)
|
||||
self.assertIn("agent-xyz", argv)
|
||||
|
||||
def test_machine_create_omits_net_when_no_allow_cidrs(self):
|
||||
with self._patch_run() as m:
|
||||
@@ -127,13 +128,13 @@ class TestArgvShapes(unittest.TestCase):
|
||||
m.call_args.args[0],
|
||||
)
|
||||
|
||||
def test_machine_delete_uses_positional_name_and_force(self):
|
||||
# delete NAME is positional; -f required so no interactive
|
||||
def test_machine_delete_uses_name_flag_and_force(self):
|
||||
# delete uses --name flag; -f required so no interactive
|
||||
# confirmation blocks teardown.
|
||||
with self._patch_run() as m:
|
||||
machine_delete("agent-xyz")
|
||||
self.assertEqual(
|
||||
["smolvm", "machine", "delete", "-f", "agent-xyz"],
|
||||
["smolvm", "machine", "delete", "--name", "agent-xyz", "-f"],
|
||||
m.call_args.args[0],
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user