@@ -13,103 +13,70 @@ func TestGatewayLogic(t *testing.T) {
1313 tests := []struct {
1414 name string
1515 envVars map [string ]string
16- args []string // CLI arguments
16+ args []string
1717 expectedModelsGateway string
18- expectedToolsGateway string
1918 expectError bool
2019 errorContains string
2120 }{
2221 {
23- name : "env_var_models_gateway_only" ,
24- envVars : map [string ]string {
25- "CAGENT_MODELS_GATEWAY" : "https://models.example.com" ,
26- },
27- args : []string {},
22+ name : "env_var_models_gateway" ,
23+ envVars : map [string ]string {"CAGENT_MODELS_GATEWAY" : "https://models.example.com" },
2824 expectedModelsGateway : "https://models.example.com" ,
2925 },
3026 {
31- name : "env_var_gateway_sets_both" ,
32- envVars : map [string ]string {
33- "CAGENT_GATEWAY" : "https://gateway.example.com" ,
34- },
35- args : []string {},
27+ name : "env_var_gateway" ,
28+ envVars : map [string ]string {"CAGENT_GATEWAY" : "https://gateway.example.com" },
3629 expectedModelsGateway : "https://gateway.example.com" ,
37- expectedToolsGateway : "https://gateway.example.com" ,
38- },
39- {
40- name : "env_var_models_and_tools_gateway_independent" ,
41- envVars : map [string ]string {
42- "CAGENT_MODELS_GATEWAY" : "https://models.example.com" ,
43- "CAGENT_TOOLS_GATEWAY" : "https://tools.example.com" ,
44- },
45- args : []string {},
46- expectedModelsGateway : "https://models.example.com" ,
47- expectedToolsGateway : "https://tools.example.com" ,
4830 },
4931 {
5032 name : "cli_flag_models_gateway" ,
5133 args : []string {"--models-gateway" , "https://cli-models.example.com" },
5234 expectedModelsGateway : "https://cli-models.example.com" ,
53- expectedToolsGateway : "" ,
5435 },
5536 {
5637 name : "cli_flag_gateway_mutually_exclusive_with_models_gateway" ,
5738 args : []string {"--gateway" , "https://gateway.example.com" , "--models-gateway" , "https://models.example.com" },
5839 expectError : true ,
5940 errorContains : "if any flags in the group [gateway models-gateway] are set none of the others can be" ,
6041 },
61- {
62- name : "cli_flag_gateway_mutually_exclusive_with_tools_gateway" ,
63- args : []string {"--gateway" , "https://gateway.example.com" , "--tools-gateway" , "https://tools.example.com" },
64- expectError : true ,
65- errorContains : "if any flags in the group [gateway tools-gateway] are set none of the others can be" ,
66- },
6742 {
6843 name : "gateway_url_canonicalization_with_main_gateway" ,
6944 envVars : map [string ]string {
7045 "CAGENT_GATEWAY" : "https://gateway.example.com/" , // Main gateway with trailing slash
7146 },
7247 args : []string {},
7348 expectedModelsGateway : "https://gateway.example.com" ,
74- expectedToolsGateway : "https://gateway.example.com" ,
7549 },
7650 // Tests for combinations of environment variables and CLI arguments
7751 {
7852 name : "env_var_overrides_same_cli_flag" ,
7953 envVars : map [string ]string {
8054 "CAGENT_MODELS_GATEWAY" : "https://env-models.example.com" ,
81- "CAGENT_TOOLS_GATEWAY" : "https://env-tools.example.com" ,
8255 },
83- args : []string {"--models-gateway" , "https://cli-models.example.com" , "--tools-gateway" , "https://cli-tools.example.com" },
56+ args : []string {"--models-gateway" , "https://cli-models.example.com" },
8457 expectedModelsGateway : "https://env-models.example.com" ,
85- expectedToolsGateway : "https://env-tools.example.com" ,
8658 },
8759 {
8860 name : "env_var_main_gateway_overrides_cli_flags" ,
8961 envVars : map [string ]string {
9062 "CAGENT_GATEWAY" : "https://env-gateway.example.com" ,
9163 },
92- args : []string {"--models-gateway" , "https://cli-gateway.example.com" , "--tools-gateway" , "https://cli-tools.example.com" },
64+ args : []string {"--models-gateway" , "https://cli-gateway.example.com" },
9365 expectedModelsGateway : "https://env-gateway.example.com" ,
94- expectedToolsGateway : "https://env-gateway.example.com" ,
9566 },
9667 {
9768 name : "cli_flag_gateway_sets_both_gateways" ,
9869 args : []string {"--gateway" , "https://cli-gateway.example.com" },
9970 expectedModelsGateway : "https://cli-gateway.example.com" ,
100- expectedToolsGateway : "https://cli-gateway.example.com" ,
10171 },
10272 {
10373 name : "env_vars_both_gateways_override_cli_gateway_flag" ,
10474 envVars : map [string ]string {
10575 "CAGENT_MODELS_GATEWAY" : "https://env-models.example.com" ,
106- "CAGENT_TOOLS_GATEWAY" : "https://env-tools.example.com" ,
10776 },
10877 args : []string {"--gateway" , "https://cli-gateway.example.com" },
10978 expectedModelsGateway : "https://env-models.example.com" ,
110- expectedToolsGateway : "https://env-tools.example.com" ,
11179 },
112- // Tests for environment variable mutual exclusion
11380 {
11481 name : "env_var_main_gateway_mutually_exclusive_with_models_gateway" ,
11582 envVars : map [string ]string {
@@ -120,22 +87,11 @@ func TestGatewayLogic(t *testing.T) {
12087 expectError : true ,
12188 errorContains : "environment variables CAGENT_GATEWAY and CAGENT_MODELS_GATEWAY cannot be set at the same time" ,
12289 },
123- {
124- name : "env_var_main_gateway_mutually_exclusive_with_tools_gateway" ,
125- envVars : map [string ]string {
126- "CAGENT_GATEWAY" : "https://gateway.example.com" ,
127- "CAGENT_TOOLS_GATEWAY" : "https://tools.example.com" ,
128- },
129- args : []string {},
130- expectError : true ,
131- errorContains : "environment variables CAGENT_GATEWAY and CAGENT_TOOLS_GATEWAY cannot be set at the same time" ,
132- },
13390 {
13491 name : "env_var_main_gateway_mutually_exclusive_with_both_specific_gateways" ,
13592 envVars : map [string ]string {
13693 "CAGENT_GATEWAY" : "https://gateway.example.com" ,
13794 "CAGENT_MODELS_GATEWAY" : "https://models.example.com" ,
138- "CAGENT_TOOLS_GATEWAY" : "https://tools.example.com" ,
13995 },
14096 args : []string {},
14197 expectError : true ,
@@ -182,7 +138,6 @@ func TestGatewayLogic(t *testing.T) {
182138
183139 // Verify expected gateway configuration
184140 assert .Equal (t , tt .expectedModelsGateway , runConfig .ModelsGateway , "Models gateway mismatch" )
185- assert .Equal (t , tt .expectedToolsGateway , runConfig .ToolsGateway , "Tools gateway mismatch" )
186141 }
187142 })
188143 }
0 commit comments