/
cache.go
36 lines (31 loc) · 1.26 KB
/
cache.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2023 Datadog, Inc.
package namingschematest
import (
"testing"
"github.com/DataDog/dd-trace-go/v2/ddtrace/mocktracer"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// NewRedisTest creates a new test for Redis naming schema.
func NewRedisTest(genSpans GenSpansFn, defaultServiceName string) func(t *testing.T) {
return func(t *testing.T) {
assertOpV0 := func(t *testing.T, spans []*mocktracer.Span) {
require.Len(t, spans, 1)
assert.Equal(t, "redis.command", spans[0].OperationName())
}
assertOpV1 := func(t *testing.T, spans []*mocktracer.Span) {
require.Len(t, spans, 1)
assert.Equal(t, "redis.command", spans[0].OperationName())
}
wantServiceNameV0 := ServiceNameAssertions{
WithDefaults: []string{defaultServiceName},
WithDDService: []string{defaultServiceName},
WithDDServiceAndOverride: []string{TestServiceOverride},
}
t.Run("ServiceName", NewServiceNameTest(genSpans, wantServiceNameV0))
t.Run("SpanName", NewSpanNameTest(genSpans, assertOpV0, assertOpV1))
}
}