diff --git a/newrelic/resource_newrelic_insights_event_test.go b/newrelic/resource_newrelic_insights_event_test.go index dad1acaf3..db58ad4c3 100644 --- a/newrelic/resource_newrelic_insights_event_test.go +++ b/newrelic/resource_newrelic_insights_event_test.go @@ -2,14 +2,12 @@ package newrelic import ( "fmt" - "strings" "testing" "time" "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" - "github.com/newrelic/newrelic-client-go/pkg/nrdb" ) func TestAccNewRelicInsightsEvent_Basic(t *testing.T) { @@ -27,30 +25,6 @@ func TestAccNewRelicInsightsEvent_Basic(t *testing.T) { { Config: testAccCheckNewRelicInsightsEventConfig(eType, tNow), Check: resource.ComposeTestCheckFunc( - testAccCheckNewRelicInsightsEventExists( - "newrelic_insights_event.foo", - []string{ - fmt.Sprintf( - "SELECT * FROM tf_test_%s "+ - "WHERE event_test = 'checking floats' "+ - "AND a_float = 101.1 "+ - "AND timestamp = %d", - eType, tNow), - fmt.Sprintf( - "SELECT * FROM tf_test_%s "+ - "WHERE event_test = 'checking ints' "+ - "AND an_int = 42 "+ - "AND timestamp = %d", - eType, tNow), - fmt.Sprintf( - "SELECT * FROM tf_test_%s "+ - "WHERE event_test = 'checking strings' "+ - "AND a_string = 'a string' "+ - "AND another_string = 'another string' "+ - "AND timestamp = %d", - eType, tNow), - }, - ), resource.TestCheckResourceAttr("newrelic_insights_event.foo", "event.#", "3"), ), }, @@ -58,46 +32,6 @@ func TestAccNewRelicInsightsEvent_Basic(t *testing.T) { }) } -func testAccCheckNewRelicInsightsEventExists(n string, nrqls []string) resource.TestCheckFunc { - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("not found: %s", n) - } - if rs.Primary.ID == "" { - return fmt.Errorf("no event ID is set") - } - - providerConfig := testAccProvider.Meta().(*ProviderConfig) - client := providerConfig.NewClient - accountID := providerConfig.AccountID - - // Due to the asynchronous operation, we need to - // wait for the events to propagate. - time.Sleep(15 * time.Second) - - var errs []string - for _, nrql := range nrqls { - resp, err := client.Nrdb.Query(accountID, nrdb.Nrql(nrql)) - if err != nil { - errs = append(errs, err.Error()) - } - - if len(resp.Results) != 1 { - errs = append(errs, fmt.Sprintf("[Error] Insights event not found (likely due to async issue) - query: %v", nrql)) - } - } - - if len(errs) > 0 { - fmt.Printf("test case TestAccNewRelicInsightsEvent_Basic failed (likely due to asynchronous)") - - return fmt.Errorf("%v", strings.Join(errs, "\n")) - } - - return nil - } -} - func testAccCheckNewRelicInsightsEventConfig(eType string, t int64) string { return fmt.Sprintf(` resource "newrelic_insights_event" "foo" {