Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
matthagenbuch committed Feb 12, 2024
1 parent efc53fa commit 784739b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion exporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"strings"
"testing"
"time"

"github.com/lightstep/terraform-provider-lightstep/client"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -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)
Expand All @@ -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:
}
}

0 comments on commit 784739b

Please sign in to comment.