diff --git a/tests/remote/check_alert_source_usage.tftest.hcl b/tests/remote/check_alert_source_usage.tftest.hcl index 07d1f4de..e03cbfc1 100644 --- a/tests/remote/check_alert_source_usage.tftest.hcl +++ b/tests/remote/check_alert_source_usage.tftest.hcl @@ -113,6 +113,11 @@ run "resource_check_alert_source_usage_create_with_all_fields" { error_message = replace(var.error_unexpected_resource_fields, "TYPE", var.check_alert_source_usage) } + assert { + condition = opslevel_check_alert_source_usage.test.alert_type == var.alert_type + error_message = "wrong alert_type of opslevel_check_alert_source_usage resource" + } + assert { condition = opslevel_check_alert_source_usage.test.category == var.category error_message = "wrong category of opslevel_check_alert_source_usage resource" diff --git a/tests/remote/check_custom_event.tftest.hcl b/tests/remote/check_custom_event.tftest.hcl new file mode 100644 index 00000000..c395eb1f --- /dev/null +++ b/tests/remote/check_custom_event.tftest.hcl @@ -0,0 +1,232 @@ +# variables { +# resource_name = "opslevel_check_custom_event" + + +# # -- check_custom_event fields -- +# # required fields +# integration = "(Sample) Cart" +# pass_pending = true +# service_selector = ".[] | select(.service == \"datadog\") | .service" +# success_condition = ".[] | select(.service == \"datadog\") | .success" + +# # optional fields +# message = null + +# # -- check base fields -- +# # required fields +# category = null +# level = null +# name = "TF Test Check Custom Event" + +# # optional fields +# enable_on = null +# enabled = true +# filter = null +# notes = "Notes on TF Check Custom Event" +# owner = null +# } + +# run "from_filter_get_filter_id" { +# command = plan + +# variables { +# connective = null +# } + +# module { +# source = "./filter" +# } +# } + +# run "from_integration_module" { +# command = plan + +# variables { +# name = "(Sample) Cart" +# } + +# module { +# source = "./integration" +# } +# } + +# run "from_rubric_category_get_category_id" { +# command = plan + +# variables { +# name = "" +# } + +# module { +# source = "./rubric_category" +# } +# } + +# run "from_rubric_level_get_level_id" { +# command = plan + +# variables { +# description = null +# index = null +# name = "" +# } + +# module { +# source = "./rubric_level" +# } +# } + +# run "from_team_get_owner_id" { +# command = plan + +# variables { +# aliases = null +# name = "" +# parent = null +# responsibilities = null +# } + +# module { +# source = "./team" +# } +# } + +# run "resource_check_custom_event_create_with_all_fields" { + +# variables { +# integration = run.from_integration_module.first_integration.id +# message = var.message +# pass_pending = var.pass_pending +# service_selector = var.service_selector +# success_condition = var.success_condition + +# category = run.from_rubric_category_get_category_id.first_category.id +# enable_on = var.enable_on +# enabled = var.enabled +# filter = run.from_filter_get_filter_id.first_filter.id +# level = run.from_rubric_level_get_level_id.greatest_level.id +# name = var.name +# notes = var.notes +# owner = run.from_team_get_owner_id.first_team.id +# } + +# module { +# source = "./check_custom_event" +# } + +# assert { +# condition = alltrue([ +# can(opslevel_check_custom_event.test.category), +# can(opslevel_check_custom_event.test.enable_on), +# can(opslevel_check_custom_event.test.enabled), +# can(opslevel_check_custom_event.test.filter), +# can(opslevel_check_custom_event.test.id), +# can(opslevel_check_custom_event.test.integration), +# can(opslevel_check_custom_event.test.level), +# can(opslevel_check_custom_event.test.message), +# can(opslevel_check_custom_event.test.name), +# can(opslevel_check_custom_event.test.notes), +# can(opslevel_check_custom_event.test.owner), +# can(opslevel_check_custom_event.test.pass_pending), +# can(opslevel_check_custom_event.test.service_selector), +# can(opslevel_check_custom_event.test.success_condition), +# ]) +# error_message = replace(var.error_unexpected_resource_fields, "TYPE", var.resource_name) +# } + +# assert { +# condition = opslevel_check_custom_event.test.category == var.category +# error_message = format( +# "expected '%v' but got '%v'", +# var.category, +# opslevel_service_tag.test.category, +# ) +# } + +# assert { +# condition = opslevel_check_custom_event.test.enable_on == var.enable_on +# error_message = format( +# "expected '%v' but got '%v'", +# var.enable_on, +# opslevel_service_tag.test.enable_on, +# ) +# } + +# assert { +# condition = opslevel_check_custom_event.test.enabled == var.enabled +# error_message = format( +# "expected '%v' but got '%v'", +# var.enabled, +# opslevel_service_tag.test.enabled, +# ) +# } + +# assert { +# condition = opslevel_check_custom_event.test.filter == var.filter +# error_message = format( +# "expected '%v' but got '%v'", +# var.filter, +# opslevel_service_tag.test.filter, +# ) +# } + +# assert { +# condition = startswith(opslevel_check_custom_event.test.id, var.id_prefix) +# error_message = replace(var.error_wrong_id, "TYPE", var.resource_name) +# } + +# assert { +# condition = opslevel_check_custom_event.test.integration == var.integration +# error_message = format( +# "expected '%v' but got '%v'", +# var.integration, +# opslevel_service_tag.test.integration, +# ) +# } + +# assert { +# condition = opslevel_check_custom_event.test.level == var.level +# error_message = format( +# "expected '%v' but got '%v'", +# var.level, +# opslevel_service_tag.test.level, +# ) +# } + +# assert { +# condition = opslevel_check_custom_event.test.message == var.message +# error_message = format( +# "expected '%v' but got '%v'", +# var.message, +# opslevel_service_tag.test.message, +# ) +# } + +# assert { +# condition = opslevel_check_custom_event.test.name == var.name +# error_message = format( +# "expected '%v' but got '%v'", +# var.name, +# opslevel_service_tag.test.name, +# ) +# } + +# assert { +# condition = opslevel_check_custom_event.test.notes == var.notes +# error_message = format( +# "expected '%v' but got '%v'", +# var.notes, +# opslevel_service_tag.test.notes, +# ) +# } + +# assert { +# condition = opslevel_check_custom_event.test.owner == var.owner +# error_message = format( +# "expected '%v' but got '%v'", +# var.owner, +# opslevel_service_tag.test.owner, +# ) +# } + +# } diff --git a/tests/remote/check_custom_event/base_variables.tf b/tests/remote/check_custom_event/base_variables.tf new file mode 120000 index 00000000..dbe1fa17 --- /dev/null +++ b/tests/remote/check_custom_event/base_variables.tf @@ -0,0 +1 @@ +../check_base/base_variables.tf \ No newline at end of file diff --git a/tests/remote/check_custom_event/main.tf b/tests/remote/check_custom_event/main.tf index 46409041..dbc073fe 100644 --- a/tests/remote/check_custom_event/main.tf +++ b/tests/remote/check_custom_event/main.tf @@ -1 +1,17 @@ -# TODO +resource "opslevel_check_custom_event" "test" { + integration = var.integration + message = var.message + pass_pending = var.pass_pending + service_selector = var.service_selector + success_condition = var.success_condition + + # -- check base fields -- + category = var.category + enable_on = var.enable_on + enabled = var.enabled + filter = var.filter + level = var.level + name = var.name + notes = var.notes + owner = var.owner +} diff --git a/tests/remote/check_custom_event/variables.tf b/tests/remote/check_custom_event/variables.tf index e69de29b..71c8f8bb 100644 --- a/tests/remote/check_custom_event/variables.tf +++ b/tests/remote/check_custom_event/variables.tf @@ -0,0 +1,25 @@ +variable "integration" { + type = string + description = "The integration id this check will use." +} + +variable "message" { + type = string + description = "The check result message template. It is compiled with Liquid and formatted in Markdown." + default = null +} + +variable "pass_pending" { + type = bool + description = "True if this check should pass by default. Otherwise the default 'pending' state counts as a failure." +} + +variable "service_selector" { + type = string + description = "A jq expression that will be ran against your payload. This will parse out the service identifier." +} + +variable "success_condition" { + type = string + description = "A jq expression that will be ran against your payload. A truthy value will result in the check passing." +} diff --git a/tests/remote/integration.tftest.hcl b/tests/remote/integration.tftest.hcl index 63a6e438..41fa9076 100644 --- a/tests/remote/integration.tftest.hcl +++ b/tests/remote/integration.tftest.hcl @@ -3,6 +3,17 @@ variables { integrations_all = "opslevel_integrations" } +run "resource_integration_create_with_all_fields" { + + variables { + external_id = var.external_id + } + + module { + source = "./integration" + } +} + run "datasource_integrations_all" { module { diff --git a/tests/remote/integration/main.tf b/tests/remote/integration/main.tf index d14a1c6e..6991f904 100644 --- a/tests/remote/integration/main.tf +++ b/tests/remote/integration/main.tf @@ -10,7 +10,7 @@ data "opslevel_integration" "first_integration_by_id" { data "opslevel_integration" "first_integration_by_name" { filter { field = "name" - value = data.opslevel_integrations.all.integrations[0].name + value = var.name != null ? var.name : data.opslevel_integrations.all.integrations[0].name } } diff --git a/tests/remote/integration/outputs.tf b/tests/remote/integration/outputs.tf new file mode 100644 index 00000000..9ecec21b --- /dev/null +++ b/tests/remote/integration/outputs.tf @@ -0,0 +1,6 @@ +output "first_integration" { + value = data.opslevel_integration.first_integration_by_id +} +output "integration_by_name" { + value = data.opslevel_integration.first_integration_by_name +} diff --git a/tests/remote/integration/variables.tf b/tests/remote/integration/variables.tf index 02301f59..a38bd4e7 100644 --- a/tests/remote/integration/variables.tf +++ b/tests/remote/integration/variables.tf @@ -1 +1,5 @@ -# Placeholder for integration_aws? +variable "name" { + type = string + description = "The name of the integration" + default = null +}