| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
// Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT. |
| 5 |
// To regenerate this file run "make genpdata". |
| 6 |
|
| 7 |
package pcommon |
| 8 |
|
| 9 |
import ( |
| 10 |
"testing" |
| 11 |
|
| 12 |
"github.com/stretchr/testify/assert" |
| 13 |
|
| 14 |
"go.opentelemetry.io/collector/pdata/internal" |
| 15 |
) |
| 16 |
|
| 17 |
func TestInstrumentationScope_MoveTo(t *testing.T) { |
| 18 |
ms := generateTestInstrumentationScope() |
| 19 |
dest := NewInstrumentationScope() |
| 20 |
ms.MoveTo(dest) |
| 21 |
assert.Equal(t, NewInstrumentationScope(), ms) |
| 22 |
assert.Equal(t, generateTestInstrumentationScope(), dest) |
| 23 |
dest.MoveTo(dest) |
| 24 |
assert.Equal(t, generateTestInstrumentationScope(), dest) |
| 25 |
sharedState := internal.NewState() |
| 26 |
sharedState.MarkReadOnly() |
| 27 |
assert.Panics(t, func() { ms.MoveTo(newInstrumentationScope(internal.NewInstrumentationScope(), sharedState)) }) |
| 28 |
assert.Panics(t, func() { newInstrumentationScope(internal.NewInstrumentationScope(), sharedState).MoveTo(dest) }) |
| 29 |
} |
| 30 |
|
| 31 |
func TestInstrumentationScope_CopyTo(t *testing.T) { |
| 32 |
ms := NewInstrumentationScope() |
| 33 |
orig := NewInstrumentationScope() |
| 34 |
orig.CopyTo(ms) |
| 35 |
assert.Equal(t, orig, ms) |
| 36 |
orig = generateTestInstrumentationScope() |
| 37 |
orig.CopyTo(ms) |
| 38 |
assert.Equal(t, orig, ms) |
| 39 |
sharedState := internal.NewState() |
| 40 |
sharedState.MarkReadOnly() |
| 41 |
assert.Panics(t, func() { ms.CopyTo(newInstrumentationScope(internal.NewInstrumentationScope(), sharedState)) }) |
| 42 |
} |
| 43 |
|
| 44 |
func TestInstrumentationScope_Name(t *testing.T) { |
| 45 |
ms := NewInstrumentationScope() |
| 46 |
assert.Empty(t, ms.Name()) |
| 47 |
ms.SetName("test_name") |
| 48 |
assert.Equal(t, "test_name", ms.Name()) |
| 49 |
sharedState := internal.NewState() |
| 50 |
sharedState.MarkReadOnly() |
| 51 |
assert.Panics(t, func() { newInstrumentationScope(internal.NewInstrumentationScope(), sharedState).SetName("test_name") }) |
| 52 |
} |
| 53 |
|
| 54 |
func TestInstrumentationScope_Version(t *testing.T) { |
| 55 |
ms := NewInstrumentationScope() |
| 56 |
assert.Empty(t, ms.Version()) |
| 57 |
ms.SetVersion("test_version") |
| 58 |
assert.Equal(t, "test_version", ms.Version()) |
| 59 |
sharedState := internal.NewState() |
| 60 |
sharedState.MarkReadOnly() |
| 61 |
assert.Panics(t, func() { |
| 62 |
newInstrumentationScope(internal.NewInstrumentationScope(), sharedState).SetVersion("test_version") |
| 63 |
}) |
| 64 |
} |
| 65 |
|
| 66 |
func TestInstrumentationScope_Attributes(t *testing.T) { |
| 67 |
ms := NewInstrumentationScope() |
| 68 |
assert.Equal(t, NewMap(), ms.Attributes()) |
| 69 |
ms.getOrig().Attributes = internal.GenTestKeyValueSlice() |
| 70 |
assert.Equal(t, Map(internal.GenTestMapWrapper()), ms.Attributes()) |
| 71 |
} |
| 72 |
|
| 73 |
func TestInstrumentationScope_DroppedAttributesCount(t *testing.T) { |
| 74 |
ms := NewInstrumentationScope() |
| 75 |
assert.Equal(t, uint32(0), ms.DroppedAttributesCount()) |
| 76 |
ms.SetDroppedAttributesCount(uint32(13)) |
| 77 |
assert.Equal(t, uint32(13), ms.DroppedAttributesCount()) |
| 78 |
sharedState := internal.NewState() |
| 79 |
sharedState.MarkReadOnly() |
| 80 |
assert.Panics(t, func() { |
| 81 |
newInstrumentationScope(internal.NewInstrumentationScope(), sharedState).SetDroppedAttributesCount(uint32(13)) |
| 82 |
}) |
| 83 |
} |
| 84 |
|
| 85 |
func generateTestInstrumentationScope() InstrumentationScope { |
| 86 |
return newInstrumentationScope(internal.GenTestInstrumentationScope(), internal.NewState()) |
| 87 |
} |