|
| 1 | +run "test_cursor_cli_basic" { |
| 2 | + command = plan |
| 3 | + |
| 4 | + variables { |
| 5 | + agent_id = "test-agent-123" |
| 6 | + folder = "/home/coder/projects" |
| 7 | + } |
| 8 | + |
| 9 | + assert { |
| 10 | + condition = coder_env.status_slug.name == "CODER_MCP_APP_STATUS_SLUG" |
| 11 | + error_message = "Status slug environment variable should be set correctly" |
| 12 | + } |
| 13 | + |
| 14 | + assert { |
| 15 | + condition = coder_env.status_slug.value == "cursorcli" |
| 16 | + error_message = "Status slug value should be 'cursorcli'" |
| 17 | + } |
| 18 | + |
| 19 | + assert { |
| 20 | + condition = var.folder == "/home/coder/projects" |
| 21 | + error_message = "Folder variable should be set correctly" |
| 22 | + } |
| 23 | + |
| 24 | + assert { |
| 25 | + condition = var.agent_id == "test-agent-123" |
| 26 | + error_message = "Agent ID variable should be set correctly" |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +run "test_cursor_cli_with_api_key" { |
| 31 | + command = plan |
| 32 | + |
| 33 | + variables { |
| 34 | + agent_id = "test-agent-456" |
| 35 | + folder = "/home/coder/workspace" |
| 36 | + api_key = "test-api-key-123" |
| 37 | + } |
| 38 | + |
| 39 | + assert { |
| 40 | + condition = coder_env.cursor_api_key[0].name == "CURSOR_API_KEY" |
| 41 | + error_message = "Cursor API key environment variable should be set correctly" |
| 42 | + } |
| 43 | + |
| 44 | + assert { |
| 45 | + condition = coder_env.cursor_api_key[0].value == "test-api-key-123" |
| 46 | + error_message = "Cursor API key value should match the input" |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +run "test_cursor_cli_with_custom_options" { |
| 51 | + command = plan |
| 52 | + |
| 53 | + variables { |
| 54 | + agent_id = "test-agent-789" |
| 55 | + folder = "/home/coder/custom" |
| 56 | + order = 5 |
| 57 | + group = "development" |
| 58 | + icon = "/icon/custom.svg" |
| 59 | + model = "sonnet-4" |
| 60 | + ai_prompt = "Help me write better code" |
| 61 | + force = false |
| 62 | + install_cursor_cli = false |
| 63 | + install_agentapi = false |
| 64 | + } |
| 65 | + |
| 66 | + assert { |
| 67 | + condition = var.order == 5 |
| 68 | + error_message = "Order variable should be set to 5" |
| 69 | + } |
| 70 | + |
| 71 | + assert { |
| 72 | + condition = var.group == "development" |
| 73 | + error_message = "Group variable should be set to 'development'" |
| 74 | + } |
| 75 | + |
| 76 | + assert { |
| 77 | + condition = var.icon == "/icon/custom.svg" |
| 78 | + error_message = "Icon variable should be set to custom icon" |
| 79 | + } |
| 80 | + |
| 81 | + assert { |
| 82 | + condition = var.model == "sonnet-4" |
| 83 | + error_message = "Model variable should be set to 'sonnet-4'" |
| 84 | + } |
| 85 | + |
| 86 | + assert { |
| 87 | + condition = var.ai_prompt == "Help me write better code" |
| 88 | + error_message = "AI prompt variable should be set correctly" |
| 89 | + } |
| 90 | + |
| 91 | + assert { |
| 92 | + condition = var.force == false |
| 93 | + error_message = "Force variable should be set to false" |
| 94 | + } |
| 95 | +} |
| 96 | + |
| 97 | +run "test_cursor_cli_with_mcp_and_rules" { |
| 98 | + command = plan |
| 99 | + |
| 100 | + variables { |
| 101 | + agent_id = "test-agent-mcp" |
| 102 | + folder = "/home/coder/mcp-test" |
| 103 | + mcp = jsonencode({ |
| 104 | + mcpServers = { |
| 105 | + test = { |
| 106 | + command = "test-server" |
| 107 | + args = ["--config", "test.json"] |
| 108 | + } |
| 109 | + } |
| 110 | + }) |
| 111 | + rules_files = { |
| 112 | + "general.md" = "# General coding rules\n- Write clean code\n- Add comments" |
| 113 | + "security.md" = "# Security rules\n- Never commit secrets\n- Validate inputs" |
| 114 | + } |
| 115 | + } |
| 116 | + |
| 117 | + assert { |
| 118 | + condition = var.mcp != null |
| 119 | + error_message = "MCP configuration should be provided" |
| 120 | + } |
| 121 | + |
| 122 | + assert { |
| 123 | + condition = var.rules_files != null |
| 124 | + error_message = "Rules files should be provided" |
| 125 | + } |
| 126 | + |
| 127 | + assert { |
| 128 | + condition = length(var.rules_files) == 2 |
| 129 | + error_message = "Should have 2 rules files" |
| 130 | + } |
| 131 | +} |
| 132 | + |
| 133 | +run "test_cursor_cli_with_scripts" { |
| 134 | + command = plan |
| 135 | + |
| 136 | + variables { |
| 137 | + agent_id = "test-agent-scripts" |
| 138 | + folder = "/home/coder/scripts" |
| 139 | + pre_install_script = "echo 'Pre-install script'" |
| 140 | + post_install_script = "echo 'Post-install script'" |
| 141 | + } |
| 142 | + |
| 143 | + assert { |
| 144 | + condition = var.pre_install_script == "echo 'Pre-install script'" |
| 145 | + error_message = "Pre-install script should be set correctly" |
| 146 | + } |
| 147 | + |
| 148 | + assert { |
| 149 | + condition = var.post_install_script == "echo 'Post-install script'" |
| 150 | + error_message = "Post-install script should be set correctly" |
| 151 | + } |
| 152 | +} |
0 commit comments