|
15 | 15 | package adapters_test
|
16 | 16 |
|
17 | 17 | import (
|
18 |
| - "errors" |
19 | 18 | "fmt"
|
20 | 19 | "net/url"
|
21 | 20 | "reflect"
|
@@ -302,66 +301,53 @@ func TestAddTAConfigToPromConfig(t *testing.T) {
|
302 | 301 |
|
303 | 302 | func TestValidatePromConfig(t *testing.T) {
|
304 | 303 | testCases := []struct {
|
305 |
| - description string |
306 |
| - config map[interface{}]interface{} |
307 |
| - targetAllocatorEnabled bool |
308 |
| - targetAllocatorRewriteEnabled bool |
309 |
| - expectedError error |
| 304 | + description string |
| 305 | + config map[interface{}]interface{} |
| 306 | + targetAllocatorEnabled bool |
| 307 | + expectedError error |
310 | 308 | }{
|
311 | 309 | {
|
312 |
| - description: "target_allocator and rewrite enabled", |
313 |
| - config: map[interface{}]interface{}{}, |
314 |
| - targetAllocatorEnabled: true, |
315 |
| - targetAllocatorRewriteEnabled: true, |
316 |
| - expectedError: nil, |
| 310 | + description: "target_allocator enabled", |
| 311 | + config: map[interface{}]interface{}{}, |
| 312 | + targetAllocatorEnabled: true, |
| 313 | + expectedError: nil, |
317 | 314 | },
|
318 | 315 | {
|
319 | 316 | description: "target_allocator enabled, target_allocator section present",
|
320 | 317 | config: map[interface{}]interface{}{
|
321 | 318 | "target_allocator": map[interface{}]interface{}{},
|
322 | 319 | },
|
323 |
| - targetAllocatorEnabled: true, |
324 |
| - targetAllocatorRewriteEnabled: false, |
325 |
| - expectedError: nil, |
| 320 | + targetAllocatorEnabled: true, |
| 321 | + expectedError: nil, |
326 | 322 | },
|
327 | 323 | {
|
328 | 324 | description: "target_allocator enabled, config section present",
|
329 | 325 | config: map[interface{}]interface{}{
|
330 | 326 | "config": map[interface{}]interface{}{},
|
331 | 327 | },
|
332 |
| - targetAllocatorEnabled: true, |
333 |
| - targetAllocatorRewriteEnabled: false, |
334 |
| - expectedError: nil, |
335 |
| - }, |
336 |
| - { |
337 |
| - description: "target_allocator enabled, neither section present", |
338 |
| - config: map[interface{}]interface{}{}, |
339 |
| - targetAllocatorEnabled: true, |
340 |
| - targetAllocatorRewriteEnabled: false, |
341 |
| - expectedError: errors.New("either target allocator or prometheus config needs to be present"), |
| 328 | + targetAllocatorEnabled: true, |
| 329 | + expectedError: nil, |
342 | 330 | },
|
343 | 331 | {
|
344 | 332 | description: "target_allocator disabled, config section present",
|
345 | 333 | config: map[interface{}]interface{}{
|
346 | 334 | "config": map[interface{}]interface{}{},
|
347 | 335 | },
|
348 |
| - targetAllocatorEnabled: false, |
349 |
| - targetAllocatorRewriteEnabled: false, |
350 |
| - expectedError: nil, |
| 336 | + targetAllocatorEnabled: false, |
| 337 | + expectedError: nil, |
351 | 338 | },
|
352 | 339 | {
|
353 |
| - description: "target_allocator disabled, config section not present", |
354 |
| - config: map[interface{}]interface{}{}, |
355 |
| - targetAllocatorEnabled: false, |
356 |
| - targetAllocatorRewriteEnabled: false, |
357 |
| - expectedError: fmt.Errorf("no %s available as part of the configuration", "prometheusConfig"), |
| 340 | + description: "target_allocator disabled, config section not present", |
| 341 | + config: map[interface{}]interface{}{}, |
| 342 | + targetAllocatorEnabled: false, |
| 343 | + expectedError: fmt.Errorf("no %s available as part of the configuration", "prometheusConfig"), |
358 | 344 | },
|
359 | 345 | }
|
360 | 346 |
|
361 | 347 | for _, testCase := range testCases {
|
362 | 348 | testCase := testCase
|
363 | 349 | t.Run(testCase.description, func(t *testing.T) {
|
364 |
| - err := ta.ValidatePromConfig(testCase.config, testCase.targetAllocatorEnabled, testCase.targetAllocatorRewriteEnabled) |
| 350 | + err := ta.ValidatePromConfig(testCase.config, testCase.targetAllocatorEnabled) |
365 | 351 | assert.Equal(t, testCase.expectedError, err)
|
366 | 352 | })
|
367 | 353 | }
|
|
0 commit comments