mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* Update vendor * Implement generic forwarder * Update CHANGELOG.md * Fix function invocation * Add 10 second timeout to Dial() * Apply review suggestions * Remove exportTracesUsingClient method for simplicity * Directly forward ptrace.Traces to remove unnecessary marshaling/unmarshaling * Remove getQueueList method * Refactor handling config change in manager.go * Asynchronously shutdown queue lists to reduce time in critical section * Remove grpc.WithBlock() option
69 lines
1.1 KiB
Go
69 lines
1.1 KiB
Go
package otlpgrpc
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/grafana/dskit/flagext"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestConfig_Validate(t *testing.T) {
|
|
type fields struct {
|
|
Endpoints flagext.StringSlice
|
|
TLS TLSConfig
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "ReturnsNoErrorForValidInsecureConfig",
|
|
fields: fields{
|
|
Endpoints: nil,
|
|
TLS: TLSConfig{
|
|
Insecure: true,
|
|
},
|
|
},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "ReturnsNoErrorForValidSecureConfig",
|
|
fields: fields{
|
|
Endpoints: nil,
|
|
TLS: TLSConfig{
|
|
Insecure: false,
|
|
CertFile: "/test/path",
|
|
},
|
|
},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "ReturnsErrorWithInsecureFalseAndNoCertFile",
|
|
fields: fields{
|
|
Endpoints: nil,
|
|
TLS: TLSConfig{
|
|
Insecure: false,
|
|
CertFile: "",
|
|
},
|
|
},
|
|
wantErr: true,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
cfg := &Config{
|
|
Endpoints: tt.fields.Endpoints,
|
|
TLS: tt.fields.TLS,
|
|
}
|
|
|
|
err := cfg.Validate()
|
|
if tt.wantErr {
|
|
require.Error(t, err)
|
|
} else {
|
|
require.NoError(t, err)
|
|
}
|
|
})
|
|
}
|
|
}
|