From 374ed85593346e70619bc9b34f91ce7a0acede4a Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:17:19 -0700 Subject: [PATCH] update tests --- pkg/ottl/contexts/internal/resource_test.go | 9 ----- pkg/ottl/contexts/internal/scope_test.go | 9 ----- .../contexts/ottldatapoint/datapoint_test.go | 13 ------- pkg/ottl/contexts/ottllog/log_test.go | 24 +------------ pkg/ottl/contexts/ottlscope/scope_test.go | 13 +------ pkg/ottl/contexts/ottlspan/span_test.go | 24 +------------ .../ottlspanevent/span_events_test.go | 35 +------------------ 7 files changed, 4 insertions(+), 123 deletions(-) diff --git a/pkg/ottl/contexts/internal/resource_test.go b/pkg/ottl/contexts/internal/resource_test.go index 71100ec95122..f1b251a3e22e 100644 --- a/pkg/ottl/contexts/internal/resource_test.go +++ b/pkg/ottl/contexts/internal/resource_test.go @@ -28,15 +28,6 @@ func TestResourcePathGetSetter(t *testing.T) { newVal any modified func(resource pcommon.Resource) }{ - { - name: "resource", - path: nil, - orig: refResource, - newVal: pcommon.NewResource(), - modified: func(resource pcommon.Resource) { - pcommon.NewResource().CopyTo(resource) - }, - }, { name: "resource schema_url", path: &TestPath[*resourceContext]{ diff --git a/pkg/ottl/contexts/internal/scope_test.go b/pkg/ottl/contexts/internal/scope_test.go index 1f9837fc8d2b..84f0c653b587 100644 --- a/pkg/ottl/contexts/internal/scope_test.go +++ b/pkg/ottl/contexts/internal/scope_test.go @@ -27,15 +27,6 @@ func TestScopePathGetSetter(t *testing.T) { newVal any modified func(is pcommon.InstrumentationScope) }{ - { - name: "instrumentation_scope", - path: nil, - orig: refIS, - newVal: pcommon.NewInstrumentationScope(), - modified: func(is pcommon.InstrumentationScope) { - pcommon.NewInstrumentationScope().CopyTo(is) - }, - }, { name: "instrumentation_scope name", path: &TestPath[*instrumentationScopeContext]{ diff --git a/pkg/ottl/contexts/ottldatapoint/datapoint_test.go b/pkg/ottl/contexts/ottldatapoint/datapoint_test.go index 1da5f4309e0a..a63542f74c99 100644 --- a/pkg/ottl/contexts/ottldatapoint/datapoint_test.go +++ b/pkg/ottl/contexts/ottldatapoint/datapoint_test.go @@ -1923,8 +1923,6 @@ func createAttributeTelemetry(attributes pcommon.Map) { } func Test_newPathGetSetter_Metric(t *testing.T) { - refMetric := createMetricTelemetry() - newMetric := pmetric.NewMetric() newMetric.SetName("new name") @@ -1935,17 +1933,6 @@ func Test_newPathGetSetter_Metric(t *testing.T) { newVal any modified func(metric pmetric.Metric) }{ - { - name: "metric", - path: &internal.TestPath[TransformContext]{ - N: "metric", - }, - orig: refMetric, - newVal: newMetric, - modified: func(metric pmetric.Metric) { - newMetric.CopyTo(metric) - }, - }, { name: "metric name", path: &internal.TestPath[TransformContext]{ diff --git a/pkg/ottl/contexts/ottllog/log_test.go b/pkg/ottl/contexts/ottllog/log_test.go index a4efc98091be..43c2c848dddf 100644 --- a/pkg/ottl/contexts/ottllog/log_test.go +++ b/pkg/ottl/contexts/ottllog/log_test.go @@ -27,7 +27,7 @@ var ( ) func Test_newPathGetSetter(t *testing.T) { - refLog, refIS, refResource := createTelemetry("string") + refLog, _, _ := createTelemetry("string") newAttrs := pcommon.NewMap() newAttrs.PutStr("hello", "world") @@ -596,28 +596,6 @@ func Test_newPathGetSetter(t *testing.T) { log.SetDroppedAttributesCount(20) }, }, - { - name: "instrumentation_scope", - path: &internal.TestPath[TransformContext]{ - N: "instrumentation_scope", - }, - orig: refIS, - newVal: pcommon.NewInstrumentationScope(), - modified: func(_ plog.LogRecord, il pcommon.InstrumentationScope, _ pcommon.Resource, _ pcommon.Map) { - pcommon.NewInstrumentationScope().CopyTo(il) - }, - }, - { - name: "resource", - path: &internal.TestPath[TransformContext]{ - N: "resource", - }, - orig: refResource, - newVal: pcommon.NewResource(), - modified: func(_ plog.LogRecord, _ pcommon.InstrumentationScope, resource pcommon.Resource, _ pcommon.Map) { - pcommon.NewResource().CopyTo(resource) - }, - }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/ottl/contexts/ottlscope/scope_test.go b/pkg/ottl/contexts/ottlscope/scope_test.go index bd2e899f96fb..4b392a43ece1 100644 --- a/pkg/ottl/contexts/ottlscope/scope_test.go +++ b/pkg/ottl/contexts/ottlscope/scope_test.go @@ -17,7 +17,7 @@ import ( ) func Test_newPathGetSetter(t *testing.T) { - refIS, refResource := createTelemetry() + refIS, _ := createTelemetry() newAttrs := pcommon.NewMap() newAttrs.PutStr("hello", "world") @@ -382,17 +382,6 @@ func Test_newPathGetSetter(t *testing.T) { is.SetVersion("next") }, }, - { - name: "resource", - path: &internal.TestPath[TransformContext]{ - N: "resource", - }, - orig: refResource, - newVal: pcommon.NewResource(), - modified: func(_ pcommon.InstrumentationScope, resource pcommon.Resource, _ pcommon.Map) { - pcommon.NewResource().CopyTo(resource) - }, - }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/ottl/contexts/ottlspan/span_test.go b/pkg/ottl/contexts/ottlspan/span_test.go index 967feac6e27a..dd4e7de5d69d 100644 --- a/pkg/ottl/contexts/ottlspan/span_test.go +++ b/pkg/ottl/contexts/ottlspan/span_test.go @@ -26,7 +26,7 @@ var ( ) func Test_newPathGetSetter(t *testing.T) { - refSpan, refIS, refResource := createTelemetry() + refSpan, _, _ := createTelemetry() newAttrs := pcommon.NewMap() newAttrs.PutStr("hello", "world") @@ -649,28 +649,6 @@ func Test_newPathGetSetter(t *testing.T) { span.Status().SetMessage("bad span") }, }, - { - name: "instrumentation_scope", - path: &internal.TestPath[TransformContext]{ - N: "instrumentation_scope", - }, - orig: refIS, - newVal: pcommon.NewInstrumentationScope(), - modified: func(_ ptrace.Span, il pcommon.InstrumentationScope, _ pcommon.Resource, _ pcommon.Map) { - pcommon.NewInstrumentationScope().CopyTo(il) - }, - }, - { - name: "resource", - path: &internal.TestPath[TransformContext]{ - N: "resource", - }, - orig: refResource, - newVal: pcommon.NewResource(), - modified: func(_ ptrace.Span, _ pcommon.InstrumentationScope, resource pcommon.Resource, _ pcommon.Map) { - pcommon.NewResource().CopyTo(resource) - }, - }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/ottl/contexts/ottlspanevent/span_events_test.go b/pkg/ottl/contexts/ottlspanevent/span_events_test.go index 90b0c9781704..daf5ce3229ca 100644 --- a/pkg/ottl/contexts/ottlspanevent/span_events_test.go +++ b/pkg/ottl/contexts/ottlspanevent/span_events_test.go @@ -20,7 +20,7 @@ import ( var spanID2 = [8]byte{8, 7, 6, 5, 4, 3, 2, 1} func Test_newPathGetSetter(t *testing.T) { - refSpanEvent, refSpan, refIS, refResource := createTelemetry() + refSpanEvent, _, _, _ := createTelemetry() newAttrs := pcommon.NewMap() newAttrs.PutStr("hello", "world") @@ -405,39 +405,6 @@ func Test_newPathGetSetter(t *testing.T) { spanEvent.SetDroppedAttributesCount(20) }, }, - { - name: "instrumentation_scope", - path: &internal.TestPath[TransformContext]{ - N: "instrumentation_scope", - }, - orig: refIS, - newVal: pcommon.NewInstrumentationScope(), - modified: func(_ ptrace.SpanEvent, _ ptrace.Span, il pcommon.InstrumentationScope, _ pcommon.Resource, _ pcommon.Map) { - pcommon.NewInstrumentationScope().CopyTo(il) - }, - }, - { - name: "resource", - path: &internal.TestPath[TransformContext]{ - N: "resource", - }, - orig: refResource, - newVal: pcommon.NewResource(), - modified: func(_ ptrace.SpanEvent, _ ptrace.Span, _ pcommon.InstrumentationScope, resource pcommon.Resource, _ pcommon.Map) { - pcommon.NewResource().CopyTo(resource) - }, - }, - { - name: "span", - path: &internal.TestPath[TransformContext]{ - N: "span", - }, - orig: refSpan, - newVal: ptrace.NewSpan(), - modified: func(_ ptrace.SpanEvent, span ptrace.Span, _ pcommon.InstrumentationScope, _ pcommon.Resource, _ pcommon.Map) { - ptrace.NewSpan().CopyTo(span) - }, - }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {