diff --git a/exporter/exporter_test.go b/exporter/exporter_test.go index b467e6c..16d492d 100644 --- a/exporter/exporter_test.go +++ b/exporter/exporter_test.go @@ -9,6 +9,7 @@ import ( "os" "strings" "testing" + "time" "github.com/lightstep/terraform-provider-lightstep/client" "github.com/stretchr/testify/assert" @@ -107,6 +108,8 @@ EOT`, } func TestRunExport(t *testing.T) { + done := make(chan struct{}) + var server *httptest.Server server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { assert.Equal(t, "/public/v0.2/blars-org/projects/blars/metric_dashboards/123abc", r.URL.Path) @@ -124,11 +127,19 @@ func TestRunExport(t *testing.T) { _, err = w.Write(body) assert.NoError(t, err) w.WriteHeader(http.StatusOK) + close(done) })) defer server.Close() os.Setenv("LIGHTSTEP_API_KEY", "api-key") os.Setenv("LIGHTSTEP_ORG", "blars-org") os.Setenv("LIGHTSTEP_API_URL", server.URL) - Run("exporter", "export", "lightstep_dashboard", "blars", "123abc") + err := Run("exporter", "export", "lightstep_dashboard", "blars", "123abc") + assert.NoError(t, err) + + select { + case <-time.After(10 * time.Second): + t.Fatal("timeout waiting for HTTP handler to be exercised") + case <-done: + } }