|
|
|
@@ -6,7 +6,8 @@ run "test_with_all_scripts" {
|
|
|
|
|
|
|
|
|
|
variables {
|
|
|
|
|
agent_id = "test-agent-id"
|
|
|
|
|
module_directory = "$HOME/.coder-modules/test/example"
|
|
|
|
|
agent_name = "test-agent"
|
|
|
|
|
module_directory = ".test-module"
|
|
|
|
|
pre_install_script = "echo 'pre-install'"
|
|
|
|
|
install_script = "echo 'install'"
|
|
|
|
|
post_install_script = "echo 'post-install'"
|
|
|
|
@@ -52,7 +53,7 @@ run "test_with_all_scripts" {
|
|
|
|
|
|
|
|
|
|
# install should sync-want pre_install
|
|
|
|
|
assert {
|
|
|
|
|
condition = can(regex("sync want test-example-install_script test-example-pre_install_script", coder_script.install_script.script))
|
|
|
|
|
condition = can(regex("sync want test-agent-install_script test-agent-pre_install_script", coder_script.install_script.script))
|
|
|
|
|
error_message = "Install script should sync-want pre_install_script when pre_install is provided"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -99,27 +100,14 @@ run "test_with_all_scripts" {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
run "test_invalid_module_directory" {
|
|
|
|
|
command = plan
|
|
|
|
|
|
|
|
|
|
variables {
|
|
|
|
|
agent_id = "test-agent-id"
|
|
|
|
|
module_directory = "$HOME/.coder-modules/test"
|
|
|
|
|
install_script = "echo 'install'"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
expect_failures = [
|
|
|
|
|
var.module_directory,
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Test with only install_script (minimum required input)
|
|
|
|
|
run "test_install_only" {
|
|
|
|
|
command = plan
|
|
|
|
|
|
|
|
|
|
variables {
|
|
|
|
|
agent_id = "test-agent-id"
|
|
|
|
|
module_directory = "$HOME/.coder-modules/test/example"
|
|
|
|
|
agent_name = "test-agent"
|
|
|
|
|
module_directory = ".test-module"
|
|
|
|
|
install_script = "echo 'install'"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -152,7 +140,8 @@ run "test_install_and_start" {
|
|
|
|
|
|
|
|
|
|
variables {
|
|
|
|
|
agent_id = "test-agent-id"
|
|
|
|
|
module_directory = "$HOME/.coder-modules/test/example"
|
|
|
|
|
agent_name = "test-agent"
|
|
|
|
|
module_directory = ".test-module"
|
|
|
|
|
install_script = "echo 'install'"
|
|
|
|
|
start_script = "echo 'start'"
|
|
|
|
|
}
|
|
|
|
@@ -184,7 +173,7 @@ run "test_install_and_start" {
|
|
|
|
|
|
|
|
|
|
# start should sync-want install (no post_install)
|
|
|
|
|
assert {
|
|
|
|
|
condition = can(regex("sync want test-example-start_script test-example-install_script", coder_script.start_script[0].script))
|
|
|
|
|
condition = can(regex("sync want test-agent-start_script test-agent-install_script", coder_script.start_script[0].script))
|
|
|
|
|
error_message = "Start script should sync-want install_script"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -195,7 +184,8 @@ run "test_with_mock_data" {
|
|
|
|
|
|
|
|
|
|
variables {
|
|
|
|
|
agent_id = "mock-agent"
|
|
|
|
|
module_directory = "$HOME/.coder-modules/test/mock"
|
|
|
|
|
agent_name = "mock-agent"
|
|
|
|
|
module_directory = ".mock-module"
|
|
|
|
|
install_script = "echo 'install'"
|
|
|
|
|
start_script = "echo 'start'"
|
|
|
|
|
}
|
|
|
|
@@ -243,25 +233,26 @@ run "test_with_mock_data" {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Test sync naming derived from module_directory
|
|
|
|
|
run "test_script_naming_from_module_directory" {
|
|
|
|
|
# Test script naming with custom agent_name
|
|
|
|
|
run "test_script_naming" {
|
|
|
|
|
command = plan
|
|
|
|
|
|
|
|
|
|
variables {
|
|
|
|
|
agent_id = "test-agent"
|
|
|
|
|
module_directory = "$HOME/.coder-modules/custom/name"
|
|
|
|
|
agent_name = "custom-name"
|
|
|
|
|
module_directory = ".test-module"
|
|
|
|
|
install_script = "echo 'install'"
|
|
|
|
|
start_script = "echo 'start'"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = can(regex("custom-name-install_script", coder_script.install_script.script))
|
|
|
|
|
error_message = "Install script should derive sync names from module_directory"
|
|
|
|
|
error_message = "Install script should use custom agent_name in sync commands"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = can(regex("custom-name-start_script", coder_script.start_script[0].script))
|
|
|
|
|
error_message = "Start script should derive sync names from module_directory"
|
|
|
|
|
error_message = "Start script should use custom agent_name in sync commands"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -271,7 +262,8 @@ run "test_install_syncs_with_pre_install" {
|
|
|
|
|
|
|
|
|
|
variables {
|
|
|
|
|
agent_id = "test-agent-id"
|
|
|
|
|
module_directory = "$HOME/.coder-modules/test/example"
|
|
|
|
|
agent_name = "test-agent"
|
|
|
|
|
module_directory = ".test-module"
|
|
|
|
|
pre_install_script = "echo 'pre-install'"
|
|
|
|
|
install_script = "echo 'install'"
|
|
|
|
|
}
|
|
|
|
@@ -282,7 +274,7 @@ run "test_install_syncs_with_pre_install" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = can(regex("sync want test-example-install_script test-example-pre_install_script", coder_script.install_script.script))
|
|
|
|
|
condition = can(regex("sync want test-agent-install_script test-agent-pre_install_script", coder_script.install_script.script))
|
|
|
|
|
error_message = "Install script should sync-want pre_install_script"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -293,7 +285,8 @@ run "test_start_syncs_with_post_install" {
|
|
|
|
|
|
|
|
|
|
variables {
|
|
|
|
|
agent_id = "test-agent-id"
|
|
|
|
|
module_directory = "$HOME/.coder-modules/test/example"
|
|
|
|
|
agent_name = "test-agent"
|
|
|
|
|
module_directory = ".test-module"
|
|
|
|
|
install_script = "echo 'install'"
|
|
|
|
|
post_install_script = "echo 'post-install'"
|
|
|
|
|
start_script = "echo 'start'"
|
|
|
|
@@ -301,13 +294,13 @@ run "test_start_syncs_with_post_install" {
|
|
|
|
|
|
|
|
|
|
# start should sync-want both install and post_install
|
|
|
|
|
assert {
|
|
|
|
|
condition = can(regex("sync want test-example-start_script test-example-install_script test-example-post_install_script", coder_script.start_script[0].script))
|
|
|
|
|
condition = can(regex("sync want test-agent-start_script test-agent-install_script test-agent-post_install_script", coder_script.start_script[0].script))
|
|
|
|
|
error_message = "Start script should sync-want both install_script and post_install_script"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# post_install should sync-want install
|
|
|
|
|
assert {
|
|
|
|
|
condition = can(regex("sync want test-example-post_install_script test-example-install_script", coder_script.post_install_script[0].script))
|
|
|
|
|
condition = can(regex("sync want test-agent-post_install_script test-agent-install_script", coder_script.post_install_script[0].script))
|
|
|
|
|
error_message = "Post-install script should sync-want install_script"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -318,7 +311,8 @@ run "test_display_name_prefix_applied" {
|
|
|
|
|
|
|
|
|
|
variables {
|
|
|
|
|
agent_id = "test-agent-id"
|
|
|
|
|
module_directory = "$HOME/.coder-modules/test/example"
|
|
|
|
|
agent_name = "test-agent"
|
|
|
|
|
module_directory = ".test-module"
|
|
|
|
|
display_name_prefix = "Claude Code"
|
|
|
|
|
pre_install_script = "echo 'pre-install'"
|
|
|
|
|
install_script = "echo 'install'"
|
|
|
|
@@ -353,7 +347,8 @@ run "test_icon_applied" {
|
|
|
|
|
|
|
|
|
|
variables {
|
|
|
|
|
agent_id = "test-agent-id"
|
|
|
|
|
module_directory = "$HOME/.coder-modules/test/example"
|
|
|
|
|
agent_name = "test-agent"
|
|
|
|
|
module_directory = ".test-module"
|
|
|
|
|
icon = "/icon/claude.svg"
|
|
|
|
|
pre_install_script = "echo 'pre-install'"
|
|
|
|
|
install_script = "echo 'install'"
|
|
|
|
@@ -388,7 +383,8 @@ run "test_optional_scripts_absent_by_default" {
|
|
|
|
|
|
|
|
|
|
variables {
|
|
|
|
|
agent_id = "test-agent-id"
|
|
|
|
|
module_directory = "$HOME/.coder-modules/test/example"
|
|
|
|
|
agent_name = "test-agent"
|
|
|
|
|
module_directory = ".test-module"
|
|
|
|
|
install_script = "echo install"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -414,7 +410,8 @@ run "test_scripts_output_with_all" {
|
|
|
|
|
|
|
|
|
|
variables {
|
|
|
|
|
agent_id = "test-agent-id"
|
|
|
|
|
module_directory = "$HOME/.coder-modules/test/example"
|
|
|
|
|
agent_name = "test-agent"
|
|
|
|
|
module_directory = ".test-module"
|
|
|
|
|
pre_install_script = "echo pre"
|
|
|
|
|
install_script = "echo install"
|
|
|
|
|
post_install_script = "echo post"
|
|
|
|
@@ -427,22 +424,22 @@ run "test_scripts_output_with_all" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = output.scripts[0] == "test-example-pre_install_script"
|
|
|
|
|
condition = output.scripts[0] == "test-agent-pre_install_script"
|
|
|
|
|
error_message = "scripts[0] must be the pre-install name"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = output.scripts[1] == "test-example-install_script"
|
|
|
|
|
condition = output.scripts[1] == "test-agent-install_script"
|
|
|
|
|
error_message = "scripts[1] must be the install name"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = output.scripts[2] == "test-example-post_install_script"
|
|
|
|
|
condition = output.scripts[2] == "test-agent-post_install_script"
|
|
|
|
|
error_message = "scripts[2] must be the post-install name"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = output.scripts[3] == "test-example-start_script"
|
|
|
|
|
condition = output.scripts[3] == "test-agent-start_script"
|
|
|
|
|
error_message = "scripts[3] must be the start name"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -452,7 +449,8 @@ run "test_scripts_output_with_install_only" {
|
|
|
|
|
|
|
|
|
|
variables {
|
|
|
|
|
agent_id = "test-agent-id"
|
|
|
|
|
module_directory = "$HOME/.coder-modules/test/example"
|
|
|
|
|
agent_name = "test-agent"
|
|
|
|
|
module_directory = ".test-module"
|
|
|
|
|
install_script = "echo install"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -462,7 +460,7 @@ run "test_scripts_output_with_install_only" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = output.scripts[0] == "test-example-install_script"
|
|
|
|
|
condition = output.scripts[0] == "test-agent-install_script"
|
|
|
|
|
error_message = "scripts[0] must be the install name"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -472,7 +470,8 @@ run "test_scripts_output_with_install_and_post" {
|
|
|
|
|
|
|
|
|
|
variables {
|
|
|
|
|
agent_id = "test-agent-id"
|
|
|
|
|
module_directory = "$HOME/.coder-modules/test/example"
|
|
|
|
|
agent_name = "test-agent"
|
|
|
|
|
module_directory = ".test-module"
|
|
|
|
|
install_script = "echo install"
|
|
|
|
|
post_install_script = "echo post"
|
|
|
|
|
}
|
|
|
|
@@ -483,12 +482,12 @@ run "test_scripts_output_with_install_and_post" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = output.scripts[0] == "test-example-install_script"
|
|
|
|
|
condition = output.scripts[0] == "test-agent-install_script"
|
|
|
|
|
error_message = "scripts[0] must be the install name"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = output.scripts[1] == "test-example-post_install_script"
|
|
|
|
|
condition = output.scripts[1] == "test-agent-post_install_script"
|
|
|
|
|
error_message = "scripts[1] must be the post-install name"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -502,7 +501,8 @@ run "test_scripts_tee_stdout_and_log_file" {
|
|
|
|
|
|
|
|
|
|
variables {
|
|
|
|
|
agent_id = "test-agent-id"
|
|
|
|
|
module_directory = "$HOME/.coder-modules/test/example"
|
|
|
|
|
agent_name = "test-agent"
|
|
|
|
|
module_directory = ".test-module"
|
|
|
|
|
pre_install_script = "echo pre"
|
|
|
|
|
install_script = "echo install"
|
|
|
|
|
post_install_script = "echo post"
|
|
|
|
@@ -510,22 +510,22 @@ run "test_scripts_tee_stdout_and_log_file" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = can(regex("pre_install\\.sh 2>&1 \\| tee .*logs/pre_install\\.log", coder_script.pre_install_script[0].script))
|
|
|
|
|
condition = can(regex("pre_install.sh 2>&1 \\| tee .*logs/pre_install.log", coder_script.pre_install_script[0].script))
|
|
|
|
|
error_message = "pre_install wrapper must tee combined output to the logs/ subdirectory"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = can(regex("install\\.sh 2>&1 \\| tee .*logs/install\\.log", coder_script.install_script.script))
|
|
|
|
|
condition = can(regex("install.sh 2>&1 \\| tee .*logs/install.log", coder_script.install_script.script))
|
|
|
|
|
error_message = "install wrapper must tee combined output to the logs/ subdirectory"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = can(regex("post_install\\.sh 2>&1 \\| tee .*logs/post_install\\.log", coder_script.post_install_script[0].script))
|
|
|
|
|
condition = can(regex("post_install.sh 2>&1 \\| tee .*logs/post_install.log", coder_script.post_install_script[0].script))
|
|
|
|
|
error_message = "post_install wrapper must tee combined output to the logs/ subdirectory"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = can(regex("start\\.sh 2>&1 \\| tee .*logs/start\\.log", coder_script.start_script[0].script))
|
|
|
|
|
condition = can(regex("start.sh 2>&1 \\| tee .*logs/start.log", coder_script.start_script[0].script))
|
|
|
|
|
error_message = "start wrapper must tee combined output to the logs/ subdirectory"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -537,7 +537,8 @@ run "test_logs_nested_under_module_directory" {
|
|
|
|
|
|
|
|
|
|
variables {
|
|
|
|
|
agent_id = "test-agent-id"
|
|
|
|
|
module_directory = "$HOME/.coder-modules/test/example"
|
|
|
|
|
agent_name = "test-agent"
|
|
|
|
|
module_directory = ".test-module"
|
|
|
|
|
pre_install_script = "echo pre"
|
|
|
|
|
install_script = "echo install"
|
|
|
|
|
post_install_script = "echo post"
|
|
|
|
@@ -545,22 +546,22 @@ run "test_logs_nested_under_module_directory" {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = strcontains(coder_script.pre_install_script[0].script, "tee $HOME/.coder-modules/test/example/logs/pre_install.log")
|
|
|
|
|
condition = can(regex("tee .test-module/logs/pre_install.log", coder_script.pre_install_script[0].script))
|
|
|
|
|
error_message = "pre_install log must land under module_directory/logs"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = strcontains(coder_script.install_script.script, "tee $HOME/.coder-modules/test/example/logs/install.log")
|
|
|
|
|
condition = can(regex("tee .test-module/logs/install.log", coder_script.install_script.script))
|
|
|
|
|
error_message = "install log must land under module_directory/logs"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = strcontains(coder_script.post_install_script[0].script, "tee $HOME/.coder-modules/test/example/logs/post_install.log")
|
|
|
|
|
condition = can(regex("tee .test-module/logs/post_install.log", coder_script.post_install_script[0].script))
|
|
|
|
|
error_message = "post_install log must land under module_directory/logs"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = strcontains(coder_script.start_script[0].script, "tee $HOME/.coder-modules/test/example/logs/start.log")
|
|
|
|
|
condition = can(regex("tee .test-module/logs/start.log", coder_script.start_script[0].script))
|
|
|
|
|
error_message = "start log must land under module_directory/logs"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -568,61 +569,104 @@ run "test_logs_nested_under_module_directory" {
|
|
|
|
|
# and start sync-depend on install so the directory already exists by
|
|
|
|
|
# the time they run.
|
|
|
|
|
assert {
|
|
|
|
|
condition = strcontains(coder_script.pre_install_script[0].script, "mkdir -p $HOME/.coder-modules/test/example/logs")
|
|
|
|
|
condition = can(regex("mkdir -p .test-module/logs", coder_script.pre_install_script[0].script))
|
|
|
|
|
error_message = "pre_install script must mkdir -p the logs/ sub-path"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = strcontains(coder_script.install_script.script, "mkdir -p $HOME/.coder-modules/test/example/logs")
|
|
|
|
|
condition = can(regex("mkdir -p .test-module/logs", coder_script.install_script.script))
|
|
|
|
|
error_message = "install script must mkdir -p the logs/ sub-path"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Scripts unconditionally land under ${module_directory}/scripts/. Each
|
|
|
|
|
# script that materializes its own `.sh` file mkdirs that path first; the
|
|
|
|
|
# first script to execute creates it for the rest.
|
|
|
|
|
run "test_scripts_nested_under_module_directory" {
|
|
|
|
|
# Scripts are written to ${module_directory}/${agent_name}-utils/ so the
|
|
|
|
|
# wrapper must mkdir that directory and all script paths must nest under it.
|
|
|
|
|
run "test_scripts_nested_under_utils_directory" {
|
|
|
|
|
command = plan
|
|
|
|
|
|
|
|
|
|
variables {
|
|
|
|
|
agent_id = "test-agent-id"
|
|
|
|
|
module_directory = "$HOME/.coder-modules/test/example"
|
|
|
|
|
agent_name = "test-agent"
|
|
|
|
|
module_directory = ".test-module"
|
|
|
|
|
pre_install_script = "echo pre"
|
|
|
|
|
install_script = "echo install"
|
|
|
|
|
post_install_script = "echo post"
|
|
|
|
|
start_script = "echo start"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# pre_install and install create the utils directory.
|
|
|
|
|
assert {
|
|
|
|
|
condition = strcontains(coder_script.pre_install_script[0].script, "> $HOME/.coder-modules/test/example/scripts/pre_install.sh")
|
|
|
|
|
error_message = "pre_install script must be written under module_directory/scripts"
|
|
|
|
|
condition = can(regex("mkdir -p .test-module/test-agent-utils", coder_script.pre_install_script[0].script))
|
|
|
|
|
error_message = "pre_install script must mkdir -p the utils directory"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = strcontains(coder_script.install_script.script, "> $HOME/.coder-modules/test/example/scripts/install.sh")
|
|
|
|
|
error_message = "install script must be written under module_directory/scripts"
|
|
|
|
|
condition = can(regex("mkdir -p .test-module/test-agent-utils", coder_script.install_script.script))
|
|
|
|
|
error_message = "install script must mkdir -p the utils directory"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Every script writes its file under the utils directory.
|
|
|
|
|
assert {
|
|
|
|
|
condition = can(regex("base64 -d > .test-module/test-agent-utils/pre_install.sh", coder_script.pre_install_script[0].script))
|
|
|
|
|
error_message = "pre_install script must write to the utils directory"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = strcontains(coder_script.post_install_script[0].script, "> $HOME/.coder-modules/test/example/scripts/post_install.sh")
|
|
|
|
|
error_message = "post_install script must be written under module_directory/scripts"
|
|
|
|
|
condition = can(regex("base64 -d > .test-module/test-agent-utils/install.sh", coder_script.install_script.script))
|
|
|
|
|
error_message = "install script must write to the utils directory"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = strcontains(coder_script.start_script[0].script, "> $HOME/.coder-modules/test/example/scripts/start.sh")
|
|
|
|
|
error_message = "start script must be written under module_directory/scripts"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Only pre_install and install mkdir the scripts/ sub-path. post_install
|
|
|
|
|
# and start sync-depend on install so the directory already exists by
|
|
|
|
|
# the time they run.
|
|
|
|
|
assert {
|
|
|
|
|
condition = strcontains(coder_script.pre_install_script[0].script, "mkdir -p $HOME/.coder-modules/test/example/scripts")
|
|
|
|
|
error_message = "pre_install script must mkdir -p the scripts/ sub-path"
|
|
|
|
|
condition = can(regex("base64 -d > .test-module/test-agent-utils/post_install.sh", coder_script.post_install_script[0].script))
|
|
|
|
|
error_message = "post_install script must write to the utils directory"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = strcontains(coder_script.install_script.script, "mkdir -p $HOME/.coder-modules/test/example/scripts")
|
|
|
|
|
error_message = "install script must mkdir -p the scripts/ sub-path"
|
|
|
|
|
condition = can(regex("base64 -d > .test-module/test-agent-utils/start.sh", coder_script.start_script[0].script))
|
|
|
|
|
error_message = "start script must write to the utils directory"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Every script executes from the utils directory.
|
|
|
|
|
assert {
|
|
|
|
|
condition = can(regex(".test-module/test-agent-utils/pre_install.sh 2>&1", coder_script.pre_install_script[0].script))
|
|
|
|
|
error_message = "pre_install script must execute from the utils directory"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = can(regex(".test-module/test-agent-utils/install.sh 2>&1", coder_script.install_script.script))
|
|
|
|
|
error_message = "install script must execute from the utils directory"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = can(regex(".test-module/test-agent-utils/post_install.sh 2>&1", coder_script.post_install_script[0].script))
|
|
|
|
|
error_message = "post_install script must execute from the utils directory"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = can(regex(".test-module/test-agent-utils/start.sh 2>&1", coder_script.start_script[0].script))
|
|
|
|
|
error_message = "start script must execute from the utils directory"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# The utils directory name includes agent_name so multiple modules sharing
|
|
|
|
|
# the same module_directory do not collide.
|
|
|
|
|
run "test_utils_directory_uses_agent_name" {
|
|
|
|
|
command = plan
|
|
|
|
|
|
|
|
|
|
variables {
|
|
|
|
|
agent_id = "test-agent-id"
|
|
|
|
|
agent_name = "custom-name"
|
|
|
|
|
module_directory = ".test-module"
|
|
|
|
|
install_script = "echo install"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = can(regex("mkdir -p .test-module/custom-name-utils", coder_script.install_script.script))
|
|
|
|
|
error_message = "utils directory must include agent_name"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
|
condition = can(regex("base64 -d > .test-module/custom-name-utils/install.sh", coder_script.install_script.script))
|
|
|
|
|
error_message = "install script must be written under agent-name-specific utils directory"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|