|
| 1 | +mock_provider "coder" {} |
| 2 | + |
| 3 | +run "test_defaults" { |
| 4 | + command = plan |
| 5 | + |
| 6 | + variables { |
| 7 | + agent_id = "test-agent-123" |
| 8 | + } |
| 9 | + |
| 10 | + assert { |
| 11 | + condition = var.http_server_port == 7800 |
| 12 | + error_message = "Default port should be 7800" |
| 13 | + } |
| 14 | + |
| 15 | + assert { |
| 16 | + condition = var.http_server_log_path == "/tmp/open-webui.log" |
| 17 | + error_message = "Default log path should be /tmp/open-webui.log" |
| 18 | + } |
| 19 | + |
| 20 | + assert { |
| 21 | + condition = var.share == "owner" |
| 22 | + error_message = "Default share should be 'owner'" |
| 23 | + } |
| 24 | + |
| 25 | + assert { |
| 26 | + condition = var.open_webui_version == "latest" |
| 27 | + error_message = "Default version should be 'latest'" |
| 28 | + } |
| 29 | + |
| 30 | + assert { |
| 31 | + condition = coder_app.open-webui.subdomain == true |
| 32 | + error_message = "App should use subdomain" |
| 33 | + } |
| 34 | + |
| 35 | + assert { |
| 36 | + condition = coder_app.open-webui.display_name == "Open WebUI" |
| 37 | + error_message = "App display name should be 'Open WebUI'" |
| 38 | + } |
| 39 | +} |
| 40 | + |
| 41 | +run "test_custom_port" { |
| 42 | + command = plan |
| 43 | + |
| 44 | + variables { |
| 45 | + agent_id = "test-agent-456" |
| 46 | + http_server_port = 9000 |
| 47 | + } |
| 48 | + |
| 49 | + assert { |
| 50 | + condition = var.http_server_port == 9000 |
| 51 | + error_message = "Custom port should be 9000" |
| 52 | + } |
| 53 | + |
| 54 | + assert { |
| 55 | + condition = coder_app.open-webui.url == "http://localhost:9000" |
| 56 | + error_message = "App URL should use custom port" |
| 57 | + } |
| 58 | +} |
| 59 | + |
| 60 | +run "test_custom_log_path" { |
| 61 | + command = plan |
| 62 | + |
| 63 | + variables { |
| 64 | + agent_id = "test-agent-789" |
| 65 | + http_server_log_path = "/var/log/open-webui.log" |
| 66 | + } |
| 67 | + |
| 68 | + assert { |
| 69 | + condition = var.http_server_log_path == "/var/log/open-webui.log" |
| 70 | + error_message = "Custom log path should be set" |
| 71 | + } |
| 72 | +} |
| 73 | + |
| 74 | +run "test_share_authenticated" { |
| 75 | + command = plan |
| 76 | + |
| 77 | + variables { |
| 78 | + agent_id = "test-agent-auth" |
| 79 | + share = "authenticated" |
| 80 | + } |
| 81 | + |
| 82 | + assert { |
| 83 | + condition = coder_app.open-webui.share == "authenticated" |
| 84 | + error_message = "Share should be 'authenticated'" |
| 85 | + } |
| 86 | +} |
| 87 | + |
| 88 | +run "test_share_public" { |
| 89 | + command = plan |
| 90 | + |
| 91 | + variables { |
| 92 | + agent_id = "test-agent-public" |
| 93 | + share = "public" |
| 94 | + } |
| 95 | + |
| 96 | + assert { |
| 97 | + condition = coder_app.open-webui.share == "public" |
| 98 | + error_message = "Share should be 'public'" |
| 99 | + } |
| 100 | +} |
| 101 | + |
| 102 | +run "test_order_and_group" { |
| 103 | + command = plan |
| 104 | + |
| 105 | + variables { |
| 106 | + agent_id = "test-agent-order" |
| 107 | + order = 10 |
| 108 | + group = "AI Tools" |
| 109 | + } |
| 110 | + |
| 111 | + assert { |
| 112 | + condition = coder_app.open-webui.order == 10 |
| 113 | + error_message = "Order should be 10" |
| 114 | + } |
| 115 | + |
| 116 | + assert { |
| 117 | + condition = coder_app.open-webui.group == "AI Tools" |
| 118 | + error_message = "Group should be 'AI Tools'" |
| 119 | + } |
| 120 | +} |
| 121 | + |
| 122 | +run "test_custom_version" { |
| 123 | + command = plan |
| 124 | + |
| 125 | + variables { |
| 126 | + agent_id = "test-agent-version" |
| 127 | + open_webui_version = "0.5.0" |
| 128 | + } |
| 129 | + |
| 130 | + assert { |
| 131 | + condition = var.open_webui_version == "0.5.0" |
| 132 | + error_message = "Custom version should be '0.5.0'" |
| 133 | + } |
| 134 | +} |
| 135 | + |
| 136 | +run "test_custom_data_dir" { |
| 137 | + command = plan |
| 138 | + |
| 139 | + variables { |
| 140 | + agent_id = "test-agent-data" |
| 141 | + data_dir = "/home/coder/open-webui-data" |
| 142 | + } |
| 143 | + |
| 144 | + assert { |
| 145 | + condition = var.data_dir == "/home/coder/open-webui-data" |
| 146 | + error_message = "Custom data_dir should be set" |
| 147 | + } |
| 148 | +} |
| 149 | + |
| 150 | +run "test_default_data_dir" { |
| 151 | + command = plan |
| 152 | + |
| 153 | + variables { |
| 154 | + agent_id = "test-agent-data-default" |
| 155 | + } |
| 156 | + |
| 157 | + assert { |
| 158 | + condition = var.data_dir == ".open-webui" |
| 159 | + error_message = "Default data_dir should be '.open-webui'" |
| 160 | + } |
| 161 | +} |
| 162 | + |
| 163 | +run "test_openai_api_key" { |
| 164 | + command = plan |
| 165 | + |
| 166 | + variables { |
| 167 | + agent_id = "test-agent-openai" |
| 168 | + openai_api_key = "sk-test-key-123" |
| 169 | + } |
| 170 | + |
| 171 | + assert { |
| 172 | + condition = var.openai_api_key == "sk-test-key-123" |
| 173 | + error_message = "OpenAI API key should be set" |
| 174 | + } |
| 175 | +} |
| 176 | + |
| 177 | +run "test_default_openai_api_key" { |
| 178 | + command = plan |
| 179 | + |
| 180 | + variables { |
| 181 | + agent_id = "test-agent-openai-default" |
| 182 | + } |
| 183 | + |
| 184 | + assert { |
| 185 | + condition = var.openai_api_key == "" |
| 186 | + error_message = "Default OpenAI API key should be empty" |
| 187 | + } |
| 188 | +} |
0 commit comments