|
7 | 7 | "testing" |
8 | 8 |
|
9 | 9 | troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" |
10 | | - "github.com/stretchr/testify/assert" |
11 | 10 | "github.com/stretchr/testify/require" |
12 | 11 | ) |
13 | 12 |
|
@@ -371,6 +370,77 @@ func Test_textAnalyze(t *testing.T) { |
371 | 370 | "text-collector-1/cfile-1.txt": []byte("Yes it all SUCCEEDED"), |
372 | 371 | }, |
373 | 372 | }, |
| 373 | + |
| 374 | + { |
| 375 | + name: "compare group with integer", |
| 376 | + analyzer: troubleshootv1beta2.TextAnalyze{ |
| 377 | + Outcomes: []*troubleshootv1beta2.Outcome{ |
| 378 | + { |
| 379 | + Pass: &troubleshootv1beta2.SingleOutcome{ |
| 380 | + When: "val > 10", |
| 381 | + Message: "val is greater than 10", |
| 382 | + }, |
| 383 | + }, |
| 384 | + { |
| 385 | + Fail: &troubleshootv1beta2.SingleOutcome{ |
| 386 | + Message: "val is not greater than 10", |
| 387 | + }, |
| 388 | + }, |
| 389 | + }, |
| 390 | + CollectorName: "text-collector-1", |
| 391 | + FileName: "cfile-1.txt", |
| 392 | + RegexGroups: `value: (?P<val>\d+)`, |
| 393 | + }, |
| 394 | + expectResult: []AnalyzeResult{ |
| 395 | + { |
| 396 | + IsPass: true, |
| 397 | + IsWarn: false, |
| 398 | + IsFail: false, |
| 399 | + Title: "text-collector-1", |
| 400 | + Message: "val is greater than 10", |
| 401 | + IconKey: "kubernetes_text_analyze", |
| 402 | + IconURI: "https://troubleshoot.sh/images/analyzer-icons/text-analyze.svg?w=13&h=16", |
| 403 | + }, |
| 404 | + }, |
| 405 | + files: map[string][]byte{ |
| 406 | + "text-collector-1/cfile-1.txt": []byte("value: 15\nother: 10"), |
| 407 | + }, |
| 408 | + }, |
| 409 | + { |
| 410 | + name: "compare group with integer (failure)", |
| 411 | + analyzer: troubleshootv1beta2.TextAnalyze{ |
| 412 | + Outcomes: []*troubleshootv1beta2.Outcome{ |
| 413 | + { |
| 414 | + Pass: &troubleshootv1beta2.SingleOutcome{ |
| 415 | + When: "val > 10", |
| 416 | + Message: "val is greater than 10", |
| 417 | + }, |
| 418 | + }, |
| 419 | + { |
| 420 | + Fail: &troubleshootv1beta2.SingleOutcome{ |
| 421 | + Message: "val is not greater than 10", |
| 422 | + }, |
| 423 | + }, |
| 424 | + }, |
| 425 | + CollectorName: "text-collector-1", |
| 426 | + FileName: "cfile-1.txt", |
| 427 | + RegexGroups: `value: (?P<val>\d+)`, |
| 428 | + }, |
| 429 | + expectResult: []AnalyzeResult{ |
| 430 | + { |
| 431 | + IsPass: false, |
| 432 | + IsWarn: false, |
| 433 | + IsFail: true, |
| 434 | + Title: "text-collector-1", |
| 435 | + Message: "val is not greater than 10", |
| 436 | + IconKey: "kubernetes_text_analyze", |
| 437 | + IconURI: "https://troubleshoot.sh/images/analyzer-icons/text-analyze.svg?w=13&h=16", |
| 438 | + }, |
| 439 | + }, |
| 440 | + files: map[string][]byte{ |
| 441 | + "text-collector-1/cfile-1.txt": []byte("value: 2\nother: 10"), |
| 442 | + }, |
| 443 | + }, |
374 | 444 | } |
375 | 445 |
|
376 | 446 | for _, test := range tests { |
@@ -404,7 +474,7 @@ func Test_textAnalyze(t *testing.T) { |
404 | 474 | for _, v := range actual { |
405 | 475 | unPointered = append(unPointered, *v) |
406 | 476 | } |
407 | | - assert.ElementsMatch(t, test.expectResult, unPointered) |
| 477 | + req.ElementsMatch(test.expectResult, unPointered) |
408 | 478 | }) |
409 | 479 | } |
410 | 480 | } |
@@ -458,7 +528,7 @@ func Test_compareRegex(t *testing.T) { |
458 | 528 | actual, err := compareRegex(test.conditional, test.foundMatches) |
459 | 529 | req.NoError(err) |
460 | 530 |
|
461 | | - assert.Equal(t, test.expected, actual) |
| 531 | + req.Equal(test.expected, actual) |
462 | 532 | }) |
463 | 533 | } |
464 | 534 | } |
0 commit comments