Skip to content

Commit

Permalink
update test predicate domain_id test order
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbloss committed Aug 5, 2024
1 parent 941f4fc commit 70f6aae
Showing 1 changed file with 46 additions and 46 deletions.
92 changes: 46 additions & 46 deletions tests/remote/filter_predicate_domain_id.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ run "get_domain" {
}
}

run "resource_filter_with_domain_id_predicate_exists" {
run "resource_filter_with_domain_id_predicate_equals" {

variables {
predicates = tomap({
for pair in var.domain_id_predicates : "${pair[0]}_${pair[1]}" => {
key = pair[0],
type = pair[1],
key_data = null,
value = null
value = run.get_domain.first_domain.id
}
if contains(var.predicate_types_exists, pair[1])
if contains(var.predicate_types_equals, pair[1])
})
}

Expand All @@ -37,70 +37,78 @@ run "resource_filter_with_domain_id_predicate_exists" {
}

assert {
condition = opslevel_filter.all_predicates["domain_id_does_not_exist"].predicate[0].key == "domain_id"
condition = opslevel_filter.all_predicates["domain_id_does_not_equal"].predicate[0].key == "domain_id"
error_message = format(
"expected predicate key 'domain_id' got '%s'",
opslevel_filter.all_predicates["domain_id_does_not_exist"].predicate[0].key
opslevel_filter.all_predicates["domain_id_does_not_equal"].predicate[0].key
)
}

assert {
condition = opslevel_filter.all_predicates["domain_id_does_not_exist"].predicate[0].type == "does_not_exist"
condition = opslevel_filter.all_predicates["domain_id_does_not_equal"].predicate[0].type == "does_not_equal"
error_message = format(
"expected predicate type 'does_not_exist' got '%s'",
opslevel_filter.all_predicates["domain_id_does_not_exist"].predicate[0].type
"expected predicate type 'does_not_equal' got '%s'",
opslevel_filter.all_predicates["domain_id_does_not_equal"].predicate[0].type
)
}

assert {
condition = opslevel_filter.all_predicates["domain_id_does_not_exist"].predicate[0].key_data == null
condition = opslevel_filter.all_predicates["domain_id_does_not_equal"].predicate[0].key_data == null
error_message = var.error_expected_null_field
}

assert {
condition = opslevel_filter.all_predicates["domain_id_does_not_exist"].predicate[0].value == null
error_message = var.error_expected_null_field
condition = opslevel_filter.all_predicates["domain_id_does_not_equal"].predicate[0].value == run.get_domain.first_domain.id
error_message = format(
"expected predicate value '%s' got '%s'",
run.get_domain.first_domain.id,
opslevel_filter.all_predicates["domain_id_does_not_equal"].predicate[0].value
)
}

assert {
condition = opslevel_filter.all_predicates["domain_id_exists"].predicate[0].key == "domain_id"
condition = opslevel_filter.all_predicates["domain_id_equals"].predicate[0].key == "domain_id"
error_message = format(
"expected predicate key 'domain_id' got '%s'",
opslevel_filter.all_predicates["domain_id_exists"].predicate[0].key
opslevel_filter.all_predicates["domain_id_equals"].predicate[0].key
)
}

assert {
condition = opslevel_filter.all_predicates["domain_id_exists"].predicate[0].type == "exists"
condition = opslevel_filter.all_predicates["domain_id_equals"].predicate[0].type == "equals"
error_message = format(
"expected predicate type 'exists' got '%s'",
opslevel_filter.all_predicates["domain_id_exists"].predicate[0].type
"expected predicate type 'equals' got '%s'",
opslevel_filter.all_predicates["domain_id_equals"].predicate[0].type
)
}

assert {
condition = opslevel_filter.all_predicates["domain_id_exists"].predicate[0].key_data == null
condition = opslevel_filter.all_predicates["domain_id_equals"].predicate[0].key_data == null
error_message = var.error_expected_null_field
}

assert {
condition = opslevel_filter.all_predicates["domain_id_exists"].predicate[0].value == null
error_message = var.error_expected_null_field
condition = opslevel_filter.all_predicates["domain_id_equals"].predicate[0].value == run.get_domain.first_domain.id
error_message = format(
"expected predicate value '%s' got '%s'",
run.get_domain.first_domain.id,
opslevel_filter.all_predicates["domain_id_equals"].predicate[0].type
)
}

}

run "resource_filter_with_domain_id_predicate_equals" {
run "resource_filter_with_domain_id_predicate_exists" {

variables {
predicates = tomap({
for pair in var.domain_id_predicates : "${pair[0]}_${pair[1]}" => {
key = pair[0],
type = pair[1],
key_data = null,
value = run.get_domain.first_domain.id
value = null
}
if contains(var.predicate_types_equals, pair[1])
if contains(var.predicate_types_exists, pair[1])
})
}

Expand All @@ -109,63 +117,55 @@ run "resource_filter_with_domain_id_predicate_equals" {
}

assert {
condition = opslevel_filter.all_predicates["domain_id_does_not_equal"].predicate[0].key == "domain_id"
condition = opslevel_filter.all_predicates["domain_id_does_not_exist"].predicate[0].key == "domain_id"
error_message = format(
"expected predicate key 'domain_id' got '%s'",
opslevel_filter.all_predicates["domain_id_does_not_equal"].predicate[0].key
opslevel_filter.all_predicates["domain_id_does_not_exist"].predicate[0].key
)
}

assert {
condition = opslevel_filter.all_predicates["domain_id_does_not_equal"].predicate[0].type == "does_not_equal"
condition = opslevel_filter.all_predicates["domain_id_does_not_exist"].predicate[0].type == "does_not_exist"
error_message = format(
"expected predicate type 'does_not_equal' got '%s'",
opslevel_filter.all_predicates["domain_id_does_not_equal"].predicate[0].type
"expected predicate type 'does_not_exist' got '%s'",
opslevel_filter.all_predicates["domain_id_does_not_exist"].predicate[0].type
)
}

assert {
condition = opslevel_filter.all_predicates["domain_id_does_not_equal"].predicate[0].key_data == null
condition = opslevel_filter.all_predicates["domain_id_does_not_exist"].predicate[0].key_data == null
error_message = var.error_expected_null_field
}

assert {
condition = opslevel_filter.all_predicates["domain_id_does_not_equal"].predicate[0].value == run.get_domain.first_domain.id
error_message = format(
"expected predicate value '%s' got '%s'",
run.get_domain.first_domain.id,
opslevel_filter.all_predicates["domain_id_does_not_equal"].predicate[0].value
)
condition = opslevel_filter.all_predicates["domain_id_does_not_exist"].predicate[0].value == null
error_message = var.error_expected_null_field
}

assert {
condition = opslevel_filter.all_predicates["domain_id_equals"].predicate[0].key == "domain_id"
condition = opslevel_filter.all_predicates["domain_id_exists"].predicate[0].key == "domain_id"
error_message = format(
"expected predicate key 'domain_id' got '%s'",
opslevel_filter.all_predicates["domain_id_equals"].predicate[0].key
opslevel_filter.all_predicates["domain_id_exists"].predicate[0].key
)
}

assert {
condition = opslevel_filter.all_predicates["domain_id_equals"].predicate[0].type == "equals"
condition = opslevel_filter.all_predicates["domain_id_exists"].predicate[0].type == "exists"
error_message = format(
"expected predicate type 'equals' got '%s'",
opslevel_filter.all_predicates["domain_id_equals"].predicate[0].type
"expected predicate type 'exists' got '%s'",
opslevel_filter.all_predicates["domain_id_exists"].predicate[0].type
)
}

assert {
condition = opslevel_filter.all_predicates["domain_id_equals"].predicate[0].key_data == null
condition = opslevel_filter.all_predicates["domain_id_exists"].predicate[0].key_data == null
error_message = var.error_expected_null_field
}

assert {
condition = opslevel_filter.all_predicates["domain_id_equals"].predicate[0].value == run.get_domain.first_domain.id
error_message = format(
"expected predicate value '%s' got '%s'",
run.get_domain.first_domain.id,
opslevel_filter.all_predicates["domain_id_equals"].predicate[0].type
)
condition = opslevel_filter.all_predicates["domain_id_exists"].predicate[0].value == null
error_message = var.error_expected_null_field
}

}

0 comments on commit 70f6aae

Please sign in to comment.