Expand pipeline panes and select the verified Docker client endpoint
This commit is contained in:
@@ -16,6 +16,41 @@ spec.loader.exec_module(setup)
|
||||
|
||||
|
||||
class DockerSetupTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
directory = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(directory.cleanup)
|
||||
environment = patch.dict(os.environ, {"XDG_CONFIG_HOME": directory.name})
|
||||
environment.start()
|
||||
self.addCleanup(environment.stop)
|
||||
|
||||
def test_verified_client_default_preserves_unrelated_settings_and_warns_on_override(self):
|
||||
path = Path(os.environ["XDG_CONFIG_HOME"])/"pipelines/client.json"
|
||||
path.parent.mkdir()
|
||||
path.write_text('{"server_url":"ws://old/connect","custom":"keep"}')
|
||||
with tempfile.TemporaryDirectory() as directory, patch.dict(os.environ, {"PIPELINES_URL":"ws://old/connect"}):
|
||||
setup.Setup(directory).configure_client("ws://127.0.0.1:8081/connect")
|
||||
self.assertEqual(setup.json.loads(path.read_text()), {"server_url":"ws://127.0.0.1:8081/connect","custom":"keep"})
|
||||
self.assertEqual(path.stat().st_mode & 0o777, 0o600)
|
||||
|
||||
def test_client_config_symlink_and_malformed_content_are_not_overwritten(self):
|
||||
path = Path(os.environ["XDG_CONFIG_HOME"])/"pipelines/client.json"
|
||||
path.parent.mkdir()
|
||||
target = path.parent/"custom.json"
|
||||
target.write_text("private custom settings")
|
||||
path.symlink_to(target)
|
||||
with self.assertRaises(ValueError): setup.Setup(".").configure_client("ws://127.0.0.1:8081/connect")
|
||||
self.assertEqual(target.read_text(),"private custom settings")
|
||||
path.unlink()
|
||||
path.write_text("not JSON")
|
||||
with self.assertRaises(ValueError): setup.Setup(".").configure_client("ws://127.0.0.1:8081/connect")
|
||||
self.assertEqual(path.read_text(), "not JSON")
|
||||
|
||||
def test_host_verification_rejects_wrong_unconfigured_server(self):
|
||||
def runner(command, **kwargs):
|
||||
return subprocess.CompletedProcess(command, 0, stdout='{"ntfy":{"health":"not configured"}}', stderr="")
|
||||
with patch.object(setup.shutil,"which",return_value="/fixture/go"), self.assertRaises(ValueError):
|
||||
setup.Setup(".",runner=runner).verify_host_endpoint("ws://127.0.0.1:8081/connect")
|
||||
|
||||
def test_validation_primes_its_own_service_and_passes_model_as_argument(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root=Path(directory);(root/".env").write_text("CUSTOM=keep\n")
|
||||
@@ -231,6 +266,8 @@ fi
|
||||
out = "127.0.0.1:8081\n"
|
||||
if fail and (fail in args or (fail=="login" and "exec opencode auth login" in args[-1]) or (fail=="provider-check" and any("provider-check" in arg for arg in args))):
|
||||
code, out = 9, "private provider data/token"
|
||||
if fail == "host" and command[0] != "docker" and args[-2:] == ["status", "--json"]:
|
||||
code, out = 9, '{"ntfy":{"health":"not configured"}}'
|
||||
return subprocess.CompletedProcess(command, code, stdout=out, stderr="")
|
||||
|
||||
args = setup.arguments([] if existing else ["--ntfy-url", "http://192.168.1.20:8090",
|
||||
@@ -250,6 +287,8 @@ fi
|
||||
self.assertLess(next(i for i,c in enumerate(calls) if "token" in c), next(i for i,c in enumerate(calls) if "build" in c))
|
||||
self.assertLess(next(i for i,c in enumerate(calls) if "exec opencode auth login" in c[-1]), next(i for i,c in enumerate(calls) if "--force-recreate" in c))
|
||||
self.assertTrue(any("curl --config -" in " ".join(c) for c in calls))
|
||||
config = Path(os.environ["XDG_CONFIG_HOME"])/"pipelines/client.json"
|
||||
self.assertEqual(setup.json.loads(config.read_text())["server_url"],"ws://127.0.0.1:8081/connect")
|
||||
|
||||
def test_reinstall_preserves_configuration_tokens_and_provider_setup(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
@@ -273,7 +312,7 @@ fi
|
||||
self.assertTrue(Path(directory, "secrets/ntfy-token.txt").stat().st_size)
|
||||
|
||||
def test_status_and_publication_failures_are_not_success(self):
|
||||
for failure in ["status", "sh", "provider-check"]:
|
||||
for failure in ["status", "sh", "provider-check", "host"]:
|
||||
with tempfile.TemporaryDirectory() as directory, self.assertRaises(ValueError):
|
||||
self.exercise(directory, fail=failure)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user