Skip to content

Commit

Permalink
fix(dashboards): fixed integration tests of dashboards
Browse files Browse the repository at this point in the history
  • Loading branch information
shashank-reddy-nr committed Oct 14, 2024
1 parent ec6d4d3 commit 073c578
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions pkg/dashboards/dashboards_api_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ func TestIntegrationDashboard_Variables(t *testing.T) {

// Test vars
dashboardName := "newrelic-client-go test-dashboard-" + mock.RandSeq(5)
ignoreTimeRangeValue := true
excludedValue := true
dashboardInput := DashboardInput{
Description: "Test description",
Name: dashboardName,
Expand Down Expand Up @@ -314,8 +316,8 @@ func TestIntegrationDashboard_Variables(t *testing.T) {
},
Name: "variable",
Options: &DashboardVariableOptionsInput{
IgnoreTimeRange: true,
Excluded: true,
IgnoreTimeRange: &ignoreTimeRangeValue,
Excluded: &excludedValue,
},
NRQLQuery: &DashboardVariableNRQLQueryInput{
AccountIDs: []int{testAccountID},
Expand Down Expand Up @@ -348,11 +350,11 @@ func TestIntegrationDashboard_Variables(t *testing.T) {
assert.Equal(t, dashboardInput.Name, dash.Name)
assert.Equal(t, entities.DashboardEntityPermissions(string(dashboardInput.Permissions)), dash.Permissions)

if dash.Variables[0].Options.IgnoreTimeRange != dashboardInput.Variables[0].Options.IgnoreTimeRange {
t.Errorf("Expected value to be %v but got %v\n", dashboardInput.Variables[0].Options.IgnoreTimeRange, dash.Variables[0].Options.IgnoreTimeRange)
if dash.Variables[0].Options.IgnoreTimeRange != *dashboardInput.Variables[0].Options.IgnoreTimeRange {
t.Errorf("Expected value to be %v but got %v\n", *dashboardInput.Variables[0].Options.IgnoreTimeRange, dash.Variables[0].Options.IgnoreTimeRange)
}
if dash.Variables[0].Options.Excluded != dashboardInput.Variables[0].Options.Excluded {
t.Errorf("Expected value to be %v but got %v\n", dashboardInput.Variables[0].Options.Excluded, dash.Variables[0].Options.Excluded)
if dash.Variables[0].Options.Excluded != *dashboardInput.Variables[0].Options.Excluded {
t.Errorf("Expected value to be %v but got %v\n", *dashboardInput.Variables[0].Options.Excluded, dash.Variables[0].Options.Excluded)
}
// Input and Pages are different types so we can not easily compare them...
assert.Equal(t, len(dashboardInput.Pages), len(dash.Pages))
Expand All @@ -365,6 +367,8 @@ func TestIntegrationDashboard_Variables(t *testing.T) {
assert.Greater(t, len(dash.Pages[0].Widgets[0].RawConfiguration), 1)

// Test: DashboardUpdate
ignoreTimeRangeValue = false
excludedValue = false
updatedDashboard := DashboardInput{
Name: dash.Name,
Permissions: result.EntityResult.Permissions,
Expand Down Expand Up @@ -399,8 +403,8 @@ func TestIntegrationDashboard_Variables(t *testing.T) {
},
Name: "variableUpdated",
Options: &DashboardVariableOptionsInput{
IgnoreTimeRange: true,
Excluded: true,
IgnoreTimeRange: &ignoreTimeRangeValue,
Excluded: &excludedValue,
},
NRQLQuery: &DashboardVariableNRQLQueryInput{
AccountIDs: []int{testAccountID},
Expand Down

0 comments on commit 073c578

Please sign in to comment.