Skip to content

Commit

Permalink
Fix tests (#334)
Browse files Browse the repository at this point in the history
* fix: data.sentry_dashboard: migrate world_map to table

* fix: data.sentry_metric_alert

* fix: sentry_metric_alert
  • Loading branch information
jianyuan authored Nov 2, 2023
1 parent f8122ca commit 0d869dc
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 26 deletions.
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,12 @@ resource "sentry_dashboard" "main" {
widget {
title = "Errors by Country"
display_type = "world_map"
display_type = "table"
interval = "5m"
widget_type = "discover"
query {
fields = ["count()"]
fields = ["geo.country_code", "geo.region", "count()"]
aggregates = ["count()"]
conditions = "!event.type:transaction has:geo.country_code"
order_by = "count()"
Expand Down
4 changes: 2 additions & 2 deletions docs/resources/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ resource "sentry_dashboard" "main" {
widget {
title = "Errors by Country"
display_type = "world_map"
display_type = "table"
interval = "5m"
widget_type = "discover"
query {
fields = ["count()"]
fields = ["geo.country_code", "geo.region", "count()"]
aggregates = ["count()"]
conditions = "!event.type:transaction has:geo.country_code"
order_by = "count()"
Expand Down
4 changes: 2 additions & 2 deletions examples/kitchen-sink/demo.tf
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,12 @@ resource "sentry_dashboard" "main" {

widget {
title = "Errors by Country"
display_type = "world_map"
display_type = "table"
interval = "5m"
widget_type = "discover"

query {
fields = ["count()"]
fields = ["geo.country_code", "geo.region", "count()"]
aggregates = ["count()"]
conditions = "!event.type:transaction has:geo.country_code"
order_by = "count()"
Expand Down
4 changes: 2 additions & 2 deletions examples/resources/sentry_dashboard/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ resource "sentry_dashboard" "main" {

widget {
title = "Errors by Country"
display_type = "world_map"
display_type = "table"
interval = "5m"
widget_type = "discover"

query {
fields = ["count()"]
fields = ["geo.country_code", "geo.region", "count()"]
aggregates = ["count()"]
conditions = "!event.type:transaction has:geo.country_code"
order_by = "count()"
Expand Down
16 changes: 9 additions & 7 deletions sentry/data_source_sentry_dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ func TestAccSentryDashboardDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttr(name, "widget.#", "1"),
resource.TestCheckTypeSetElemNestedAttrs(name, "widget.*", map[string]string{
"title": "Custom Widget",
"display_type": "world_map",
"display_type": "table",
}),
resource.TestCheckResourceAttr(name, "widget.0.query.#", "1"),
resource.TestCheckTypeSetElemNestedAttrs(name, "widget.0.query.*", map[string]string{
"name": "Metric",
"conditions": "!event.type:transaction",
"conditions": "!event.type:transaction has:geo.country_code",
}),
resource.TestCheckResourceAttr(name, "widget.0.query.0.fields.#", "1"),
resource.TestCheckResourceAttr(name, "widget.0.query.0.fields.0", "count()"),
resource.TestCheckResourceAttr(name, "widget.0.query.0.fields.#", "3"),
resource.TestCheckResourceAttr(name, "widget.0.query.0.fields.0", "geo.country_code"),
resource.TestCheckResourceAttr(name, "widget.0.query.0.fields.1", "geo.region"),
resource.TestCheckResourceAttr(name, "widget.0.query.0.fields.2", "count()"),
resource.TestCheckResourceAttr(name, "widget.0.query.0.aggregates.#", "1"),
resource.TestCheckResourceAttr(name, "widget.0.query.0.aggregates.0", "count()"),
resource.TestCheckResourceAttr(name, "widget.0.layout.#", "1"),
Expand Down Expand Up @@ -71,14 +73,14 @@ resource "sentry_dashboard" "test" {
widget {
title = "Custom Widget"
display_type = "world_map"
display_type = "table"
query {
name = "Metric"
fields = ["count()"]
fields = ["geo.country_code", "geo.region", "count()"]
aggregates = ["count()"]
conditions = "!event.type:transaction"
conditions = "!event.type:transaction has:geo.country_code"
}
layout {
Expand Down
2 changes: 1 addition & 1 deletion sentry/data_source_sentry_metric_alert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ resource "sentry_metric_alert" "test" {
organization = sentry_project.test.organization
project = sentry_project.test.id
name = "%[1]s"
dataset = "transactions"
dataset = "generic_metrics"
event_types = ["transaction"]
query = "http.url:http://testservice.com/stats"
aggregate = "p50(transaction.duration)"
Expand Down
1 change: 0 additions & 1 deletion sentry/resource_sentry_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func resourceSentryDashboard() *schema.Resource {
"stacked_area",
"bar",
"table",
"world_map",
"big_number",
"top_n",
},
Expand Down
16 changes: 9 additions & 7 deletions sentry/resource_sentry_dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@ func TestAccSentryDashboard_basic(t *testing.T) {
resource.TestCheckResourceAttr(rn, "title", dashboardTitle),
resource.TestCheckResourceAttr(rn, "widget.#", "1"),
resource.TestCheckResourceAttr(rn, "widget.0.title", "Custom Widget"),
resource.TestCheckResourceAttr(rn, "widget.0.display_type", "world_map"),
resource.TestCheckResourceAttr(rn, "widget.0.display_type", "table"),
resource.TestCheckResourceAttr(rn, "widget.0.query.#", "1"),
resource.TestCheckResourceAttr(rn, "widget.0.query.0.name", "Metric"),
resource.TestCheckResourceAttr(rn, "widget.0.query.0.fields.#", "1"),
resource.TestCheckResourceAttr(rn, "widget.0.query.0.fields.0", "count()"),
resource.TestCheckResourceAttr(rn, "widget.0.query.0.fields.#", "3"),
resource.TestCheckResourceAttr(rn, "widget.0.query.0.fields.0", "geo.country_code"),
resource.TestCheckResourceAttr(rn, "widget.0.query.0.fields.1", "geo.region"),
resource.TestCheckResourceAttr(rn, "widget.0.query.0.fields.2", "count()"),
resource.TestCheckResourceAttr(rn, "widget.0.query.0.aggregates.#", "1"),
resource.TestCheckResourceAttr(rn, "widget.0.query.0.aggregates.0", "count()"),
resource.TestCheckResourceAttr(rn, "widget.0.query.0.columns.#", "0"),
resource.TestCheckResourceAttr(rn, "widget.0.query.0.field_aliases.#", "0"),
resource.TestCheckResourceAttr(rn, "widget.0.query.0.conditions", "!event.type:transaction"),
resource.TestCheckResourceAttr(rn, "widget.0.query.0.conditions", "!event.type:transaction has:geo.country_code"),
resource.TestCheckResourceAttr(rn, "widget.0.query.0.order_by", ""),
resource.TestCheckResourceAttrSet(rn, "widget.0.query.0.id"),
resource.TestCheckResourceAttrPtr(rn, "internal_id", &dashboardID),
Expand Down Expand Up @@ -97,14 +99,14 @@ resource "sentry_dashboard" "test" {
widget {
title = "Custom Widget"
display_type = "world_map"
display_type = "table"
query {
name = "Metric"
fields = ["count()"]
fields = ["geo.country_code", "geo.region", "count()"]
aggregates = ["count()"]
conditions = "!event.type:transaction"
conditions = "!event.type:transaction has:geo.country_code"
}
layout {
Expand Down
4 changes: 2 additions & 2 deletions sentry/resource_sentry_metric_alert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestAccSentryMetricAlert_basic(t *testing.T) {
resource.TestCheckResourceAttr(rn, "project", projectName),
resource.TestCheckResourceAttr(rn, "name", alertName),
resource.TestCheckResourceAttr(rn, "environment", ""),
resource.TestCheckResourceAttr(rn, "dataset", "transactions"),
resource.TestCheckResourceAttr(rn, "dataset", "generic_metrics"),
resource.TestCheckResourceAttr(rn, "event_types.#", "1"),
resource.TestCheckResourceAttr(rn, "event_types.0", "transaction"),
resource.TestCheckResourceAttr(rn, "query", "http.url:http://testservice.com/stats"),
Expand Down Expand Up @@ -122,7 +122,7 @@ resource "sentry_metric_alert" "test" {
organization = sentry_project.test.organization
project = sentry_project.test.id
name = "%[1]s"
dataset = "transactions"
dataset = "generic_metrics"
event_types = ["transaction"]
query = "http.url:http://testservice.com/stats"
aggregate = "p50(transaction.duration)"
Expand Down

0 comments on commit 0d869dc

Please sign in to comment.