@@ -66,24 +66,6 @@ func TestLoad_EnvironmentVariables(t *testing.T) {
6666 envVars map [string ]string
6767 check func (t * testing.T , cfg * Config )
6868 }{
69- {
70- name : "INSTANCE_NAME overrides Name" ,
71- envVars : map [string ]string {"INSTANCE_NAME" : "my-instance" },
72- check : func (t * testing.T , cfg * Config ) {
73- if cfg .Name != "my-instance" {
74- t .Errorf ("expected Name 'my-instance', got %q" , cfg .Name )
75- }
76- },
77- },
78- {
79- name : "NAMESPACE overrides Namespace" ,
80- envVars : map [string ]string {"NAMESPACE" : "custom-ns" },
81- check : func (t * testing.T , cfg * Config ) {
82- if cfg .Namespace != "custom-ns" {
83- t .Errorf ("expected Namespace 'custom-ns', got %q" , cfg .Namespace )
84- }
85- },
86- },
8769 {
8870 name : "GATEWAY_NAME overrides GatewayName and Name defaults to it" ,
8971 envVars : map [string ]string {"GATEWAY_NAME" : "my-gateway" },
@@ -109,81 +91,6 @@ func TestLoad_EnvironmentVariables(t *testing.T) {
10991 }
11092 },
11193 },
112- {
113- name : "GATEWAY_NAMESPACE overrides GatewayNamespace" ,
114- envVars : map [string ]string {"GATEWAY_NAMESPACE" : "gw-ns" },
115- check : func (t * testing.T , cfg * Config ) {
116- if cfg .GatewayNamespace != "gw-ns" {
117- t .Errorf ("expected GatewayNamespace 'gw-ns', got %q" , cfg .GatewayNamespace )
118- }
119- },
120- },
121- {
122- name : "ADDRESS overrides Address" ,
123- envVars : map [string ]string {"ADDRESS" : ":9999" },
124- check : func (t * testing.T , cfg * Config ) {
125- if cfg .Address != ":9999" {
126- t .Errorf ("expected Address ':9999', got %q" , cfg .Address )
127- }
128- },
129- },
130- {
131- name : "SECURE=true sets Secure" ,
132- envVars : map [string ]string {"SECURE" : "true" },
133- check : func (t * testing.T , cfg * Config ) {
134- if ! cfg .Secure {
135- t .Error ("expected Secure to be true" )
136- }
137- },
138- },
139- {
140- name : "DEBUG_MODE=true sets DebugMode" ,
141- envVars : map [string ]string {"DEBUG_MODE" : "true" },
142- check : func (t * testing.T , cfg * Config ) {
143- if ! cfg .DebugMode {
144- t .Error ("expected DebugMode to be true" )
145- }
146- },
147- },
148- {
149- name : "API_KEY_EXPIRATION_POLICY=required" ,
150- envVars : map [string ]string {"API_KEY_EXPIRATION_POLICY" : "required" },
151- check : func (t * testing.T , cfg * Config ) {
152- if cfg .APIKeyExpirationPolicy != "required" {
153- t .Errorf ("expected APIKeyExpirationPolicy 'required', got %q" , cfg .APIKeyExpirationPolicy )
154- }
155- },
156- },
157- {
158- name : "PORT sets deprecatedHTTPPort" ,
159- envVars : map [string ]string {"PORT" : "9090" },
160- check : func (t * testing.T , cfg * Config ) {
161- if cfg .deprecatedHTTPPort != "9090" {
162- t .Errorf ("expected deprecatedHTTPPort '9090', got %q" , cfg .deprecatedHTTPPort )
163- }
164- },
165- },
166- {
167- name : "TLS_CERT and TLS_KEY set TLS config" ,
168- envVars : map [string ]string {"TLS_CERT" : "/path/to/cert.pem" , "TLS_KEY" : "/path/to/key.pem" },
169- check : func (t * testing.T , cfg * Config ) {
170- if cfg .TLS .Cert != "/path/to/cert.pem" {
171- t .Errorf ("expected TLS.Cert '/path/to/cert.pem', got %q" , cfg .TLS .Cert )
172- }
173- if cfg .TLS .Key != "/path/to/key.pem" {
174- t .Errorf ("expected TLS.Key '/path/to/key.pem', got %q" , cfg .TLS .Key )
175- }
176- },
177- },
178- {
179- name : "TLS_SELF_SIGNED=true sets TLS.SelfSigned" ,
180- envVars : map [string ]string {"TLS_SELF_SIGNED" : "true" },
181- check : func (t * testing.T , cfg * Config ) {
182- if ! cfg .TLS .SelfSigned {
183- t .Error ("expected TLS.SelfSigned to be true" )
184- }
185- },
186- },
18794 }
18895
18996 // All env vars that Load() reads, to be cleared before each subtest.
0 commit comments