mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 21:50:09 +00:00
TUN-6855: Add DatagramV2Type for IP packet with trace and tracing spans
This commit is contained in:
52
tracing/identity_test.go
Normal file
52
tracing/identity_test.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package tracing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestNewIdentity(t *testing.T) {
|
||||
testCases := []struct {
|
||||
testCase string
|
||||
trace string
|
||||
valid bool
|
||||
}{
|
||||
{
|
||||
testCase: "full length trace",
|
||||
trace: "ec31ad8a01fde11fdcabe2efdce36873:52726f6cabc144f5:0:1",
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
testCase: "short trace ID",
|
||||
trace: "ad8a01fde11fdcabe2efdce36873:52726f6cabc144f5:0:1",
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
testCase: "no trace",
|
||||
trace: "",
|
||||
valid: false,
|
||||
},
|
||||
{
|
||||
testCase: "missing flags",
|
||||
trace: "ec31ad8a01fde11fdcabe2efdce36873:52726f6cabc144f5:0",
|
||||
valid: false,
|
||||
},
|
||||
{
|
||||
testCase: "missing separator",
|
||||
trace: "ec31ad8a01fde11fdcabe2efdce3687352726f6cabc144f501",
|
||||
valid: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
identity, err := NewIdentity(testCase.trace)
|
||||
if testCase.valid {
|
||||
require.NoError(t, err, testCase.testCase)
|
||||
require.Equal(t, testCase.trace, identity.String())
|
||||
} else {
|
||||
require.Error(t, err)
|
||||
require.Nil(t, identity)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user