Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit tests reproducing bugs #223

Merged
merged 1 commit into from
May 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions lightstep/resource_dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,20 @@ func TestDisplayTypeOptions(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "group.0.chart.0.query.0.display_type_options.0.comparison_window_ms", "86400000"),
),
},
{
// 🐛 empty display_type options result in unresolvable diff
Config: makeDisplayTypeConfig("line", strings.TrimSpace(`
display_type_options {
}
`)),
Check: resource.ComposeTestCheckFunc(
testAccCheckMetricDashboardExists(resourceName, &dashboard),
resource.TestCheckResourceAttr(resourceName, "dashboard_name", "test display_type_options"),
resource.TestCheckResourceAttr(resourceName, "group.0.chart.0.query.0.display", "line"),
),
// fixme this should result in an empty plan
ExpectNonEmptyPlan: true,
},
},
})
}
Expand Down Expand Up @@ -1467,3 +1481,44 @@ EOT
},
})
}

func TestAccDashboardHiddenQueriesUnresolvableDiff(t *testing.T) {
config := `
resource "lightstep_dashboard" "test" {
project_name = "` + testProject + `"
dashboard_name = "🐛 dash"
chart {
rank = 0
name = "Chart Number One"
type = "timeseries"
query {
hidden = false
hidden_queries = { a: "true" }
query_name = "a"
display = "line"
query_string = "metric cpu.utilization | delta"
}
}
}
`

var dashboard client.UnifiedDashboard
resourceName := "lightstep_dashboard.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testGetMetricDashboardDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testAccCheckMetricDashboardExists(resourceName, &dashboard),
),
// 🐛 this plan should be empty, but we omit hidden_queries["a"] from state
// because it is the top level query name (also we overwrite the value using "hidden")
ExpectNonEmptyPlan: true,
},
},
})
}
Loading