(t *testing.T)
| 458 | } |
| 459 | |
| 460 | func TestAssignVariable(t *testing.T) { |
| 461 | var tests = []struct { |
| 462 | name string |
| 463 | source string |
| 464 | matchSpec MatchSpec |
| 465 | expected bool |
| 466 | }{ |
| 467 | { |
| 468 | name: "check assignVariable handling in pass case", |
| 469 | source: ` |
| 470 | resource "aws_s3_bucket" "test-bucket" { |
| 471 | bucket = "test-bucket" |
| 472 | |
| 473 | lifecycle_rule { |
| 474 | id = "test-bucket-rule-1" |
| 475 | } |
| 476 | } |
| 477 | `, |
| 478 | matchSpec: testAssignVariableMatchSpec, |
| 479 | expected: true, |
| 480 | }, |
| 481 | { |
| 482 | name: "check assignVariable handling in fail case", |
| 483 | source: ` |
| 484 | resource "aws_s3_bucket" "test-bucket" { |
| 485 | bucket = "test-bucket" |
| 486 | |
| 487 | lifecycle_rule { |
| 488 | id = "not-bucket-name-rule-1" |
| 489 | } |
| 490 | } |
| 491 | `, |
| 492 | matchSpec: testAssignVariableMatchSpec, |
| 493 | expected: false, |
| 494 | }, |
| 495 | } |
| 496 | |
| 497 | for _, test := range tests { |
| 498 | t.Run(test.name, func(t *testing.T) { |
| 499 | block := parseFromSource(t, test.source)[0].GetBlocks()[0] |
| 500 | result := evalMatchSpec(block, &test.matchSpec, NewEmptyCustomContext()) |
| 501 | assert.Equal(t, test.expected, result, "processing variable assignments incorrectly.") |
| 502 | }) |
| 503 | } |
| 504 | } |
| 505 | |
| 506 | func TestRegexMatches(t *testing.T) { |
| 507 | var tests = []struct { |
nothing calls this directly
no test coverage detected