Skip to content

Commit

Permalink
fix(go): Fix TestActionTracing test case (#1595)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoaguirre authored Jan 13, 2025
1 parent b1869b7 commit 817be17
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions go/core/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package core
import (
"bytes"
"context"
"fmt"
"slices"
"testing"

Expand Down Expand Up @@ -114,17 +115,19 @@ func TestActionTracing(t *testing.T) {
if err != nil {
t.Fatal(err)
}
provider := "test"
tc := tracing.NewTestOnlyTelemetryClient()
r.TracingState().WriteTelemetryImmediate(tc)
const actionName = "TestTracing-inc"
a := defineAction(r, "test", actionName, atype.Custom, nil, nil, inc)
a := defineAction(r, provider, actionName, atype.Custom, nil, nil, inc)
if _, err := a.Run(context.Background(), 3, nil); err != nil {
t.Fatal(err)
}
// The same trace store is used for all tests, so there might be several traces.
// Look for this one, which has a unique name.
fullActionName := fmt.Sprintf("%s/%s", provider, actionName)
for _, td := range tc.Traces {
if td.DisplayName == actionName {
if td.DisplayName == fullActionName {
// Spot check: expect a single span.
if g, w := len(td.Spans), 1; g != w {
t.Errorf("got %d spans, want %d", g, w)
Expand Down

0 comments on commit 817be17

Please sign in to comment.