(t *testing.T)
| 330 | } |
| 331 | |
| 332 | func TestNestedMatchFunction(t *testing.T) { |
| 333 | var tests = []struct { |
| 334 | name string |
| 335 | source string |
| 336 | predicateMatchSpec MatchSpec |
| 337 | expected bool |
| 338 | }{ |
| 339 | { |
| 340 | name: "check nested match function with only inner true evaluation", |
| 341 | source: ` |
| 342 | resource "aws_ami" "example" { |
| 343 | virtualization_type = "hvm" |
| 344 | image_location = "image-XXXX" |
| 345 | kernel_id = "XXXXXXXXXX" |
| 346 | } |
| 347 | `, |
| 348 | predicateMatchSpec: testNestedMatchSpec, |
| 349 | expected: false, |
| 350 | }, |
| 351 | { |
| 352 | name: "check nested match function with no true evaluation", |
| 353 | source: ` |
| 354 | resource "aws_ami" "example" { |
| 355 | virtualization_type = "hvm" |
| 356 | } |
| 357 | `, |
| 358 | predicateMatchSpec: testNestedMatchSpec, |
| 359 | expected: false, |
| 360 | }, |
| 361 | { |
| 362 | name: "check nested match function with all true evaluation", |
| 363 | source: ` |
| 364 | resource "aws_ami" "example" { |
| 365 | virtualization_type = "paravirtual" |
| 366 | image_location = "image-XXXX" |
| 367 | kernel_id = "XXXXXXXXXX" |
| 368 | } |
| 369 | `, |
| 370 | predicateMatchSpec: testNestedMatchSpec, |
| 371 | expected: true, |
| 372 | }, |
| 373 | } |
| 374 | for _, test := range tests { |
| 375 | t.Run(test.name, func(t *testing.T) { |
| 376 | block := parseFromSource(t, test.source)[0].GetBlocks()[0] |
| 377 | result := evalMatchSpec(block, &test.predicateMatchSpec, NewEmptyCustomContext()) |
| 378 | assert.Equal(t, test.expected, result, "Nested match functions evaluating incorrectly.") |
| 379 | }) |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | func TestNotFunction(t *testing.T) { |
| 384 | var tests = []struct { |
nothing calls this directly
no test coverage detected