-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor filter integration tests part 1 (#488)
* WIP: refactor filter integration tests part 1 * WIP: refactor filter integration tests part 2 * uncomment datasources
- Loading branch information
1 parent
1623712
commit 5c9cc27
Showing
17 changed files
with
1,861 additions
and
2,296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
data "opslevel_domains" "all" {} | ||
|
||
data "opslevel_filters" "all" {} | ||
|
||
data "opslevel_repositories" "all" {} | ||
|
||
data "opslevel_services" "all" {} | ||
|
||
data "opslevel_teams" "all" {} | ||
|
||
data "opslevel_users" "all" {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
output "all_domains" { | ||
value = data.opslevel_domains.all | ||
} | ||
|
||
output "all_filters" { | ||
value = data.opslevel_filters.all | ||
} | ||
|
||
output "all_repositories" { | ||
value = data.opslevel_repositories.all | ||
} | ||
|
||
output "all_services" { | ||
value = data.opslevel_services.all | ||
} | ||
|
||
output "all_teams" { | ||
value = data.opslevel_teams.all | ||
} | ||
|
||
output "all_users" { | ||
value = data.opslevel_users.all | ||
} | ||
|
||
output "first_domain" { | ||
value = data.opslevel_domains.all.domains[0] | ||
} | ||
|
||
output "first_filter" { | ||
value = data.opslevel_filters.all.filters[0] | ||
} | ||
|
||
output "first_repository" { | ||
value = data.opslevel_repositories.all.repositories[0] | ||
} | ||
|
||
output "first_service" { | ||
value = data.opslevel_services.all.services[0] | ||
} | ||
|
||
output "first_team" { | ||
value = data.opslevel_teams.all.teams[0] | ||
} | ||
|
||
output "first_user" { | ||
value = data.opslevel_users.all.users[0] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../workspace/versions.tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,316 @@ | ||
variables { | ||
name = "TF Test Filter with aliases predicate" | ||
predicate_key = "aliases" | ||
predicate_value = "fancy" | ||
} | ||
|
||
run "resource_filter_with_aliases_predicate_contains" { | ||
|
||
variables { | ||
predicates = [ | ||
for predicate_type in var.predicate_types_contains : { | ||
key = var.predicate_key | ||
type = predicate_type, | ||
key_data = null, | ||
value = var.predicate_value | ||
} | ||
] | ||
} | ||
|
||
module { | ||
source = "./opslevel_modules/modules/filter" | ||
} | ||
|
||
assert { | ||
condition = alltrue([ | ||
opslevel_filter.this.predicate[0].key == var.predicate_key, | ||
opslevel_filter.this.predicate[1].key == var.predicate_key | ||
]) | ||
error_message = format( | ||
"expected predicate keys to all be '%v' got keys '%v'", | ||
var.predicate_key, | ||
[opslevel_filter.this.predicate[0].key, opslevel_filter.this.predicate[1].key] | ||
) | ||
} | ||
|
||
assert { | ||
condition = alltrue([ | ||
contains(var.predicate_types_contains, opslevel_filter.this.predicate[0].type), | ||
contains(var.predicate_types_contains, opslevel_filter.this.predicate[1].type) | ||
]) | ||
error_message = format( | ||
"expected predicate types to be one of '%v' got '%v'", | ||
var.predicate_types_contains, | ||
tolist([opslevel_filter.this.predicate[0].type, opslevel_filter.this.predicate[1].type]) | ||
) | ||
} | ||
|
||
assert { | ||
condition = alltrue([ | ||
opslevel_filter.this.predicate[0].key_data == null, | ||
opslevel_filter.this.predicate[1].key_data == null | ||
]) | ||
error_message = var.error_expected_null_field | ||
} | ||
|
||
assert { | ||
condition = alltrue([ | ||
opslevel_filter.this.predicate[0].value == var.predicate_value, | ||
opslevel_filter.this.predicate[1].value == var.predicate_value | ||
]) | ||
error_message = format( | ||
"expected predicate values to all be '%v' got values '%v'", | ||
var.predicate_value, | ||
[opslevel_filter.this.predicate[0].value, opslevel_filter.this.predicate[1].value] | ||
) | ||
} | ||
|
||
} | ||
|
||
run "resource_filter_with_aliases_predicate_equals" { | ||
|
||
variables { | ||
predicates = [ | ||
for predicate_type in var.predicate_types_equals : { | ||
key = var.predicate_key | ||
type = predicate_type, | ||
key_data = null, | ||
value = var.predicate_value | ||
} | ||
] | ||
} | ||
|
||
module { | ||
source = "./opslevel_modules/modules/filter" | ||
} | ||
|
||
assert { | ||
condition = alltrue([ | ||
opslevel_filter.this.predicate[0].key == var.predicate_key, | ||
opslevel_filter.this.predicate[1].key == var.predicate_key | ||
]) | ||
error_message = format( | ||
"expected predicate keys to all be '%v' got keys '%v'", | ||
var.predicate_key, | ||
[opslevel_filter.this.predicate[0].key, opslevel_filter.this.predicate[1].key] | ||
) | ||
} | ||
|
||
assert { | ||
condition = alltrue([ | ||
contains(var.predicate_types_equals, opslevel_filter.this.predicate[0].type), | ||
contains(var.predicate_types_equals, opslevel_filter.this.predicate[1].type) | ||
]) | ||
error_message = format( | ||
"expected predicate types to be one of '%v' got '%v'", | ||
var.predicate_types_equals, | ||
tolist([opslevel_filter.this.predicate[0].type, opslevel_filter.this.predicate[1].type]) | ||
) | ||
} | ||
|
||
assert { | ||
condition = alltrue([ | ||
opslevel_filter.this.predicate[0].key_data == null, | ||
opslevel_filter.this.predicate[1].key_data == null | ||
]) | ||
error_message = var.error_expected_null_field | ||
} | ||
|
||
assert { | ||
condition = alltrue([ | ||
opslevel_filter.this.predicate[0].value == var.predicate_value, | ||
opslevel_filter.this.predicate[1].value == var.predicate_value | ||
]) | ||
error_message = format( | ||
"expected predicate values to all be '%v' got values '%v'", | ||
var.predicate_value, | ||
[opslevel_filter.this.predicate[0].value, opslevel_filter.this.predicate[1].value] | ||
) | ||
} | ||
|
||
} | ||
|
||
run "resource_filter_with_aliases_predicate_exists" { | ||
|
||
variables { | ||
predicates = [ | ||
for predicate_type in var.predicate_types_exists : { | ||
key = var.predicate_key | ||
type = predicate_type, | ||
key_data = null, | ||
value = null | ||
} | ||
] | ||
} | ||
|
||
module { | ||
source = "./opslevel_modules/modules/filter" | ||
} | ||
|
||
assert { | ||
condition = alltrue([ | ||
opslevel_filter.this.predicate[0].key == var.predicate_key, | ||
opslevel_filter.this.predicate[1].key == var.predicate_key | ||
]) | ||
error_message = format( | ||
"expected predicate keys to all be '%v' got keys '%v'", | ||
var.predicate_key, | ||
[opslevel_filter.this.predicate[0].key, opslevel_filter.this.predicate[1].key] | ||
) | ||
} | ||
|
||
assert { | ||
condition = alltrue([ | ||
contains(var.predicate_types_exists, opslevel_filter.this.predicate[0].type), | ||
contains(var.predicate_types_exists, opslevel_filter.this.predicate[1].type) | ||
]) | ||
error_message = format( | ||
"expected predicate types to be one of '%v' got '%v'", | ||
var.predicate_types_exists, | ||
tolist([opslevel_filter.this.predicate[0].type, opslevel_filter.this.predicate[1].type]) | ||
) | ||
} | ||
|
||
assert { | ||
condition = alltrue([ | ||
opslevel_filter.this.predicate[0].key_data == null, | ||
opslevel_filter.this.predicate[1].key_data == null | ||
]) | ||
error_message = var.error_expected_null_field | ||
} | ||
|
||
assert { | ||
condition = alltrue([ | ||
opslevel_filter.this.predicate[0].value == null, | ||
opslevel_filter.this.predicate[1].value == null | ||
]) | ||
error_message = var.error_expected_null_field | ||
} | ||
|
||
} | ||
|
||
run "resource_filter_with_aliases_predicate_matches_regex" { | ||
|
||
variables { | ||
predicates = [ | ||
for predicate_type in var.predicate_types_matches_regex : { | ||
key = var.predicate_key | ||
type = predicate_type, | ||
key_data = null, | ||
value = var.predicate_value | ||
} | ||
] | ||
} | ||
|
||
module { | ||
source = "./opslevel_modules/modules/filter" | ||
} | ||
|
||
assert { | ||
condition = alltrue([ | ||
opslevel_filter.this.predicate[0].key == var.predicate_key, | ||
opslevel_filter.this.predicate[1].key == var.predicate_key | ||
]) | ||
error_message = format( | ||
"expected predicate keys to all be '%v' got keys '%v'", | ||
var.predicate_key, | ||
[opslevel_filter.this.predicate[0].key, opslevel_filter.this.predicate[1].key] | ||
) | ||
} | ||
|
||
assert { | ||
condition = alltrue([ | ||
contains(var.predicate_types_matches_regex, opslevel_filter.this.predicate[0].type), | ||
contains(var.predicate_types_matches_regex, opslevel_filter.this.predicate[1].type) | ||
]) | ||
error_message = format( | ||
"expected predicate types to be one of '%v' got '%v'", | ||
var.predicate_types_matches_regex, | ||
tolist([opslevel_filter.this.predicate[0].type, opslevel_filter.this.predicate[1].type]) | ||
) | ||
} | ||
|
||
assert { | ||
condition = alltrue([ | ||
opslevel_filter.this.predicate[0].key_data == null, | ||
opslevel_filter.this.predicate[1].key_data == null | ||
]) | ||
error_message = var.error_expected_null_field | ||
} | ||
|
||
assert { | ||
condition = alltrue([ | ||
opslevel_filter.this.predicate[0].value == var.predicate_value, | ||
opslevel_filter.this.predicate[1].value == var.predicate_value | ||
]) | ||
error_message = format( | ||
"expected predicate values to all be '%v' got values '%v'", | ||
var.predicate_value, | ||
[opslevel_filter.this.predicate[0].key, opslevel_filter.this.predicate[1].key] | ||
) | ||
} | ||
|
||
} | ||
|
||
run "resource_filter_with_aliases_predicate_starts_or_ends_with" { | ||
|
||
variables { | ||
predicates = [ | ||
for predicate_type in var.predicate_types_ends_or_starts_with : { | ||
key = var.predicate_key | ||
type = predicate_type, | ||
key_data = null, | ||
value = var.predicate_value | ||
} | ||
] | ||
} | ||
|
||
module { | ||
source = "./opslevel_modules/modules/filter" | ||
} | ||
|
||
assert { | ||
condition = alltrue([ | ||
opslevel_filter.this.predicate[0].key == var.predicate_key, | ||
opslevel_filter.this.predicate[1].key == var.predicate_key | ||
]) | ||
error_message = format( | ||
"expected predicate keys to all be '%v' got keys '%v'", | ||
var.predicate_key, | ||
[opslevel_filter.this.predicate[0].key, opslevel_filter.this.predicate[1].key] | ||
) | ||
} | ||
|
||
assert { | ||
condition = alltrue([ | ||
contains(var.predicate_types_ends_or_starts_with, opslevel_filter.this.predicate[0].type), | ||
contains(var.predicate_types_ends_or_starts_with, opslevel_filter.this.predicate[1].type) | ||
]) | ||
error_message = format( | ||
"expected predicate types to be one of '%v' got '%v'", | ||
var.predicate_types_ends_or_starts_with, | ||
tolist([opslevel_filter.this.predicate[0].type, opslevel_filter.this.predicate[1].type]) | ||
) | ||
} | ||
|
||
assert { | ||
condition = alltrue([ | ||
opslevel_filter.this.predicate[0].key_data == null, | ||
opslevel_filter.this.predicate[1].key_data == null | ||
]) | ||
error_message = var.error_expected_null_field | ||
} | ||
|
||
assert { | ||
condition = alltrue([ | ||
opslevel_filter.this.predicate[0].value == var.predicate_value, | ||
opslevel_filter.this.predicate[1].value == var.predicate_value | ||
]) | ||
error_message = format( | ||
"expected predicate values to all be '%v' got values '%v'", | ||
var.predicate_value, | ||
[opslevel_filter.this.predicate[0].key, opslevel_filter.this.predicate[1].key] | ||
) | ||
} | ||
|
||
} |
Oops, something went wrong.