Skip to content

Commit

Permalink
Add TestConfigLinkMutability (#5604)
Browse files Browse the repository at this point in the history
Follow up to #5567. Test the immutability of configured links.

Co-authored-by: Robert Pająk <pellared@hotmail.com>
  • Loading branch information
MrAlias and pellared committed Jul 11, 2024
1 parent 1384c27 commit eb05fd5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions trace/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,3 +643,21 @@ func TestLinkFromContext(t *testing.T) {
}
assert.Equal(t, link.Attributes[0], k1v1)
}

func TestConfigLinkMutability(t *testing.T) {
sc0 := NewSpanContext(SpanContextConfig{TraceID: [16]byte{1}})
sc1 := NewSpanContext(SpanContextConfig{TraceID: [16]byte{2}})
sc2 := NewSpanContext(SpanContextConfig{TraceID: [16]byte{3}})
l0 := Link{SpanContext: sc0}
l1 := Link{SpanContext: sc1}
l2 := Link{SpanContext: sc2}

links := []Link{l0, l1}
conf := NewSpanStartConfig(WithLinks(links...))

// Mutating passed arg should not change configured links.
links[0] = l2

want := SpanConfig{links: []Link{l0, l1}}
assert.Equal(t, want, conf)
}

0 comments on commit eb05fd5

Please sign in to comment.