Files
telemetry/pdata/pprofile/generated_sample_test.go
Florian LehnerandGitHub 8a7da59bb0 [pdata/pprofile] Update protoID for messsage Sample fields (#14652)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

https://github.com/open-telemetry/opentelemetry-proto/pull/724
introduces a breaking change to the Profiles signal.

This is a follow up to
https://github.com/open-telemetry/opentelemetry-collector/pull/14739.

<!-- Issue number if applicable -->
#### Link to tracking issue
Fixes #

<!--Describe what testing was performed and which tests were added.-->
#### Testing

<!--Describe the documentation added.-->
#### Documentation

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Signed-off-by: Florian Lehner <[email protected]>
2026-03-10 09:23:56 +00:00

89 lines
2.8 KiB
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT.
// To regenerate this file run "make genpdata".
package pprofile
import (
"testing"
"github.com/stretchr/testify/assert"
"go.opentelemetry.io/collector/pdata/internal"
"go.opentelemetry.io/collector/pdata/pcommon"
)
func TestSample_MoveTo(t *testing.T) {
ms := generateTestSample()
dest := NewSample()
ms.MoveTo(dest)
assert.Equal(t, NewSample(), ms)
assert.Equal(t, generateTestSample(), dest)
dest.MoveTo(dest)
assert.Equal(t, generateTestSample(), dest)
sharedState := internal.NewState()
sharedState.MarkReadOnly()
assert.Panics(t, func() { ms.MoveTo(newSample(internal.NewSample(), sharedState)) })
assert.Panics(t, func() { newSample(internal.NewSample(), sharedState).MoveTo(dest) })
}
func TestSample_CopyTo(t *testing.T) {
ms := NewSample()
orig := NewSample()
orig.CopyTo(ms)
assert.Equal(t, orig, ms)
orig = generateTestSample()
orig.CopyTo(ms)
assert.Equal(t, orig, ms)
sharedState := internal.NewState()
sharedState.MarkReadOnly()
assert.Panics(t, func() { ms.CopyTo(newSample(internal.NewSample(), sharedState)) })
}
func TestSample_StackIndex(t *testing.T) {
ms := NewSample()
assert.Equal(t, int32(0), ms.StackIndex())
ms.SetStackIndex(int32(13))
assert.Equal(t, int32(13), ms.StackIndex())
sharedState := internal.NewState()
sharedState.MarkReadOnly()
assert.Panics(t, func() { newSample(internal.NewSample(), sharedState).SetStackIndex(int32(13)) })
}
func TestSample_AttributeIndices(t *testing.T) {
ms := NewSample()
assert.Equal(t, pcommon.NewInt32Slice(), ms.AttributeIndices())
ms.orig.AttributeIndices = internal.GenTestInt32Slice()
assert.Equal(t, pcommon.Int32Slice(internal.GenTestInt32SliceWrapper()), ms.AttributeIndices())
}
func TestSample_LinkIndex(t *testing.T) {
ms := NewSample()
assert.Equal(t, int32(0), ms.LinkIndex())
ms.SetLinkIndex(int32(13))
assert.Equal(t, int32(13), ms.LinkIndex())
sharedState := internal.NewState()
sharedState.MarkReadOnly()
assert.Panics(t, func() { newSample(internal.NewSample(), sharedState).SetLinkIndex(int32(13)) })
}
func TestSample_Values(t *testing.T) {
ms := NewSample()
assert.Equal(t, pcommon.NewInt64Slice(), ms.Values())
ms.orig.Values = internal.GenTestInt64Slice()
assert.Equal(t, pcommon.Int64Slice(internal.GenTestInt64SliceWrapper()), ms.Values())
}
func TestSample_TimestampsUnixNano(t *testing.T) {
ms := NewSample()
assert.Equal(t, pcommon.NewUInt64Slice(), ms.TimestampsUnixNano())
ms.orig.TimestampsUnixNano = internal.GenTestUint64Slice()
assert.Equal(t, pcommon.UInt64Slice(internal.GenTestUInt64SliceWrapper()), ms.TimestampsUnixNano())
}
func generateTestSample() Sample {
return newSample(internal.GenTestSample(), internal.NewState())
}