-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change OTTL contexts to handle paths with context
- Loading branch information
Showing
27 changed files
with
1,264 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package internal | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl" | ||
) | ||
|
||
func Test_isPathToContextRoot(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
context string | ||
path ottl.Path[any] | ||
expected bool | ||
}{ | ||
{ | ||
name: "with context and empty path", | ||
context: "resource", | ||
expected: true, | ||
path: &TestPath[any]{ | ||
C: "resource", | ||
N: "", | ||
}, | ||
}, | ||
{ | ||
name: "with context and next path", | ||
context: "resource", | ||
expected: false, | ||
path: &TestPath[any]{ | ||
C: "resource", | ||
N: "", | ||
NextPath: &TestPath[any]{ | ||
N: "foo", | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "with context and path keys", | ||
context: "resource", | ||
expected: false, | ||
path: &TestPath[any]{ | ||
C: "resource", | ||
N: "", | ||
KeySlice: []ottl.Key[any]{ | ||
&TestKey[any]{}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "with both context and path name", | ||
context: "resource", | ||
expected: false, | ||
path: &TestPath[any]{ | ||
C: "resource", | ||
N: "resource", | ||
}, | ||
}, | ||
{ | ||
name: "with nil path", | ||
context: "resource", | ||
expected: true, | ||
path: nil, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
assert.Equal(t, tt.expected, isPathToContextRoot(tt.path, tt.context)) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.