From 784739b580bc897abb692aabaa10621cc6e67bc8 Mon Sep 17 00:00:00 2001 From: Matt Hagenbuch Date: Mon, 12 Feb 2024 13:38:40 -0500 Subject: [PATCH] update --- exporter/exporter_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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: + } }