Skip to content

Commit

Permalink
Remove top-level context access tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edmocosta committed Dec 18, 2024
1 parent 1fd358f commit 53242ec
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 161 deletions.
13 changes: 1 addition & 12 deletions pkg/ottl/contexts/internal/scope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,18 +335,7 @@ func TestScopePathGetSetter(t *testing.T) {
},
},
{
name: "scope",
path: &TestPath[*instrumentationScopeContext]{
C: "scope",
},
orig: refIS,
newVal: pcommon.NewInstrumentationScope(),
modified: func(is pcommon.InstrumentationScope) {
pcommon.NewInstrumentationScope().CopyTo(is)
},
},
{
name: "scope field",
name: "scope with context",
path: &TestPath[*instrumentationScopeContext]{
C: "scope",
N: "name",
Expand Down
38 changes: 4 additions & 34 deletions pkg/ottl/contexts/ottldatapoint/datapoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2232,12 +2232,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected any
}{
{
name: "resource",
path: &internal.TestPath[TransformContext]{N: "resource"},
expected: resource,
},
{
name: "resource field",
name: "resource",
path: &internal.TestPath[TransformContext]{C: "", N: "resource", NextPath: &internal.TestPath[TransformContext]{
N: "attributes",
KeySlice: []ottl.Key[TransformContext]{
Expand All @@ -2249,12 +2244,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected: "bar",
},
{
name: "resource context",
path: &internal.TestPath[TransformContext]{C: "resource"},
expected: resource,
},
{
name: "resource field with context",
name: "resource with context",
path: &internal.TestPath[TransformContext]{C: "resource", N: "attributes", KeySlice: []ottl.Key[TransformContext]{
&internal.TestKey[TransformContext]{
S: ottltest.Strp("foo"),
Expand All @@ -2264,41 +2254,21 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
},
{
name: "metric",
path: &internal.TestPath[TransformContext]{N: "metric"},
expected: metric,
},
{
name: "metric field",
path: &internal.TestPath[TransformContext]{N: "metric", NextPath: &internal.TestPath[TransformContext]{N: "name"}},
expected: metric.Name(),
},
{
name: "metric context",
path: &internal.TestPath[TransformContext]{C: "metric"},
expected: metric,
},
{
name: "metric field with context",
name: "metric with context",
path: &internal.TestPath[TransformContext]{C: "metric", N: "name"},
expected: metric.Name(),
},
{
name: "instrumentation_scope",
path: &internal.TestPath[TransformContext]{N: "instrumentation_scope"},
expected: instrumentationScope,
},
{
name: "instrumentation_scope field",
path: &internal.TestPath[TransformContext]{N: "instrumentation_scope", NextPath: &internal.TestPath[TransformContext]{N: "name"}},
expected: instrumentationScope.Name(),
},
{
name: "instrumentation_scope context",
path: &internal.TestPath[TransformContext]{C: "instrumentation_scope"},
expected: instrumentationScope,
},
{
name: "instrumentation_scope field with context",
name: "instrumentation_scope with context",
path: &internal.TestPath[TransformContext]{C: "instrumentation_scope", N: "name"},
expected: instrumentationScope.Name(),
},
Expand Down
26 changes: 3 additions & 23 deletions pkg/ottl/contexts/ottllog/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,12 +649,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected any
}{
{
name: "resource",
path: &internal.TestPath[TransformContext]{N: "resource"},
expected: resource,
},
{
name: "resource field",
name: "resource",
path: &internal.TestPath[TransformContext]{C: "", N: "resource", NextPath: &internal.TestPath[TransformContext]{
N: "attributes",
KeySlice: []ottl.Key[TransformContext]{
Expand All @@ -666,12 +661,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected: "val",
},
{
name: "resource context",
path: &internal.TestPath[TransformContext]{C: "resource"},
expected: resource,
},
{
name: "resource field with context",
name: "resource with context",
path: &internal.TestPath[TransformContext]{C: "resource", N: "attributes", KeySlice: []ottl.Key[TransformContext]{
&internal.TestKey[TransformContext]{
S: ottltest.Strp("str"),
Expand All @@ -681,21 +671,11 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
},
{
name: "instrumentation_scope",
path: &internal.TestPath[TransformContext]{N: "instrumentation_scope"},
expected: instrumentationScope,
},
{
name: "instrumentation_scope field",
path: &internal.TestPath[TransformContext]{N: "instrumentation_scope", NextPath: &internal.TestPath[TransformContext]{N: "name"}},
expected: instrumentationScope.Name(),
},
{
name: "instrumentation_scope context",
path: &internal.TestPath[TransformContext]{C: "instrumentation_scope"},
expected: instrumentationScope,
},
{
name: "instrumentation_scope field with context",
name: "instrumentation_scope with context",
path: &internal.TestPath[TransformContext]{C: "instrumentation_scope", N: "name"},
expected: instrumentationScope.Name(),
},
Expand Down
26 changes: 3 additions & 23 deletions pkg/ottl/contexts/ottlmetric/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected any
}{
{
name: "resource",
path: &internal.TestPath[TransformContext]{N: "resource"},
expected: resource,
},
{
name: "resource field",
name: "resource",
path: &internal.TestPath[TransformContext]{C: "", N: "resource", NextPath: &internal.TestPath[TransformContext]{
N: "attributes",
KeySlice: []ottl.Key[TransformContext]{
Expand All @@ -211,12 +206,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected: "bar",
},
{
name: "resource context",
path: &internal.TestPath[TransformContext]{C: "resource"},
expected: resource,
},
{
name: "resource field with context",
name: "resource with context",
path: &internal.TestPath[TransformContext]{C: "resource", N: "attributes", KeySlice: []ottl.Key[TransformContext]{
&internal.TestKey[TransformContext]{
S: ottltest.Strp("foo"),
Expand All @@ -226,21 +216,11 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
},
{
name: "instrumentation_scope",
path: &internal.TestPath[TransformContext]{N: "instrumentation_scope"},
expected: instrumentationScope,
},
{
name: "instrumentation_scope field",
path: &internal.TestPath[TransformContext]{N: "instrumentation_scope", NextPath: &internal.TestPath[TransformContext]{N: "name"}},
expected: instrumentationScope.Name(),
},
{
name: "instrumentation_scope context",
path: &internal.TestPath[TransformContext]{C: "instrumentation_scope"},
expected: instrumentationScope,
},
{
name: "instrumentation_scope field with context",
name: "instrumentation_scope with context",
path: &internal.TestPath[TransformContext]{C: "instrumentation_scope", N: "name"},
expected: instrumentationScope.Name(),
},
Expand Down
14 changes: 2 additions & 12 deletions pkg/ottl/contexts/ottlscope/scope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected any
}{
{
name: "resource",
path: &internal.TestPath[TransformContext]{N: "resource"},
expected: resource,
},
{
name: "resource field",
name: "resource",
path: &internal.TestPath[TransformContext]{C: "", N: "resource", NextPath: &internal.TestPath[TransformContext]{
N: "attributes",
KeySlice: []ottl.Key[TransformContext]{
Expand All @@ -450,12 +445,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected: "bar",
},
{
name: "resource context",
path: &internal.TestPath[TransformContext]{C: "resource"},
expected: resource,
},
{
name: "resource field with context",
name: "resource with context",
path: &internal.TestPath[TransformContext]{C: "resource", N: "attributes", KeySlice: []ottl.Key[TransformContext]{
&internal.TestKey[TransformContext]{
S: ottltest.Strp("foo"),
Expand Down
26 changes: 3 additions & 23 deletions pkg/ottl/contexts/ottlspan/span_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,12 +706,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected any
}{
{
name: "resource",
path: &internal.TestPath[TransformContext]{N: "resource"},
expected: resource,
},
{
name: "resource field",
name: "resource",
path: &internal.TestPath[TransformContext]{C: "", N: "resource", NextPath: &internal.TestPath[TransformContext]{
N: "attributes",
KeySlice: []ottl.Key[TransformContext]{
Expand All @@ -723,12 +718,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected: "bar",
},
{
name: "resource context",
path: &internal.TestPath[TransformContext]{C: "resource"},
expected: resource,
},
{
name: "resource field with context",
name: "resource with context",
path: &internal.TestPath[TransformContext]{C: "resource", N: "attributes", KeySlice: []ottl.Key[TransformContext]{
&internal.TestKey[TransformContext]{
S: ottltest.Strp("foo"),
Expand All @@ -738,21 +728,11 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
},
{
name: "instrumentation_scope",
path: &internal.TestPath[TransformContext]{N: "instrumentation_scope"},
expected: instrumentationScope,
},
{
name: "instrumentation_scope field",
path: &internal.TestPath[TransformContext]{N: "instrumentation_scope", NextPath: &internal.TestPath[TransformContext]{N: "name"}},
expected: instrumentationScope.Name(),
},
{
name: "instrumentation_scope context",
path: &internal.TestPath[TransformContext]{C: "instrumentation_scope"},
expected: instrumentationScope,
},
{
name: "instrumentation_scope field with context",
name: "instrumentation_scope with context",
path: &internal.TestPath[TransformContext]{C: "instrumentation_scope", N: "name"},
expected: instrumentationScope.Name(),
},
Expand Down
38 changes: 4 additions & 34 deletions pkg/ottl/contexts/ottlspanevent/span_events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected any
}{
{
name: "resource",
path: &internal.TestPath[TransformContext]{N: "resource"},
expected: resource,
},
{
name: "resource field",
name: "resource",
path: &internal.TestPath[TransformContext]{C: "", N: "resource", NextPath: &internal.TestPath[TransformContext]{
N: "attributes",
KeySlice: []ottl.Key[TransformContext]{
Expand All @@ -482,12 +477,7 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
expected: "bar",
},
{
name: "resource context",
path: &internal.TestPath[TransformContext]{C: "resource"},
expected: resource,
},
{
name: "resource field with context",
name: "resource with context",
path: &internal.TestPath[TransformContext]{C: "resource", N: "attributes", KeySlice: []ottl.Key[TransformContext]{
&internal.TestKey[TransformContext]{
S: ottltest.Strp("foo"),
Expand All @@ -497,41 +487,21 @@ func Test_newPathGetSetter_higherContextPath(t *testing.T) {
},
{
name: "instrumentation_scope",
path: &internal.TestPath[TransformContext]{N: "instrumentation_scope"},
expected: instrumentationScope,
},
{
name: "instrumentation_scope field",
path: &internal.TestPath[TransformContext]{N: "instrumentation_scope", NextPath: &internal.TestPath[TransformContext]{N: "name"}},
expected: instrumentationScope.Name(),
},
{
name: "instrumentation_scope context",
path: &internal.TestPath[TransformContext]{C: "instrumentation_scope"},
expected: instrumentationScope,
},
{
name: "instrumentation_scope field with context",
name: "instrumentation_scope with context",
path: &internal.TestPath[TransformContext]{C: "instrumentation_scope", N: "name"},
expected: instrumentationScope.Name(),
},
{
name: "span",
path: &internal.TestPath[TransformContext]{N: "span"},
expected: span,
},
{
name: "span field",
path: &internal.TestPath[TransformContext]{N: "span", NextPath: &internal.TestPath[TransformContext]{N: "name"}},
expected: span.Name(),
},
{
name: "span context",
path: &internal.TestPath[TransformContext]{C: "span"},
expected: span,
},
{
name: "span field with context",
name: "span with context",
path: &internal.TestPath[TransformContext]{C: "span", N: "name"},
expected: span.Name(),
},
Expand Down

0 comments on commit 53242ec

Please sign in to comment.