Skip to content

Commit cacb1d3

Browse files
committed
Log with condition and update the test cases
Signed-off-by: Doğukan Teber <[email protected]>
1 parent 4c4255e commit cacb1d3

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

gateway/gateway.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,10 @@ func setupProxy(upstreamConfig Upstream, proxyType string, description string) (
111111
return nil, err
112112
}
113113
return proxy, nil
114+
} else {
115+
logrus.Infof("%s URL configuration not provided. %s will not be set up.", description, description)
114116
}
115-
logrus.Infof("%s URL configuration not provided. %s will not be set up.", description, description)
117+
116118
return nil, nil
117119
}
118120

gateway/gateway_test.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -264,51 +264,56 @@ func TestStartGateway(t *testing.T) {
264264
expectedStatus: http.StatusNotFound,
265265
},
266266
{
267-
name: "invalid distributor proxy",
268-
config: &Config{},
269-
expectedErr: errors.New("invalid URL scheme:"),
267+
name: "invalid distributor proxy",
268+
config: &Config{
269+
Distributor: Upstream{
270+
URL: "localhost",
271+
Paths: []string{},
272+
},
273+
},
274+
expectedErr: errors.New("invalid URL scheme"),
270275
},
271276
{
272277
name: "invalid frontend proxy",
273278
config: &Config{
274279
Distributor: Upstream{
275-
URL: distributorServer.URL,
280+
URL: "localhost",
276281
Paths: []string{},
277282
},
278283
},
279-
expectedErr: errors.New("invalid URL scheme:"),
284+
expectedErr: errors.New("invalid URL scheme"),
280285
},
281286
{
282287
name: "invalid alertmanager proxy",
283288
config: &Config{
284289
Distributor: Upstream{
285-
URL: distributorServer.URL,
290+
URL: "localhost",
286291
Paths: []string{},
287292
},
288293
QueryFrontend: Upstream{
289-
URL: frontendServer.URL,
294+
URL: "localhost",
290295
Paths: []string{},
291296
},
292297
},
293-
expectedErr: errors.New("invalid URL scheme:"),
298+
expectedErr: errors.New("invalid URL scheme"),
294299
},
295300
{
296301
name: "invalid ruler proxy",
297302
config: &Config{
298303
Distributor: Upstream{
299-
URL: distributorServer.URL,
304+
URL: "localhost",
300305
Paths: []string{},
301306
},
302307
QueryFrontend: Upstream{
303-
URL: frontendServer.URL,
308+
URL: "localhost",
304309
Paths: []string{},
305310
},
306311
Alertmanager: Upstream{
307-
URL: alertmanagerServer.URL,
312+
URL: "localhost",
308313
Paths: []string{},
309314
},
310315
},
311-
expectedErr: errors.New("invalid URL scheme:"),
316+
expectedErr: errors.New("invalid URL scheme"),
312317
},
313318
}
314319

0 commit comments

Comments
 (0)