...

Source file src/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/metadata_supplier_test.go

Documentation: go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc

     1  // Copyright The OpenTelemetry Authors
     2  // SPDX-License-Identifier: Apache-2.0
     3  
     4  package otelgrpc
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/assert"
    10  	"google.golang.org/grpc/metadata"
    11  )
    12  
    13  func TestMetadataSupplier(t *testing.T) {
    14  	md := metadata.New(map[string]string{
    15  		"k1": "v1",
    16  	})
    17  	ms := &metadataSupplier{&md}
    18  
    19  	v1 := ms.Get("k1")
    20  	assert.Equal(t, v1, "v1")
    21  
    22  	ms.Set("k2", "v2")
    23  
    24  	v1 = ms.Get("k1")
    25  	v2 := ms.Get("k2")
    26  	assert.Equal(t, v1, "v1")
    27  	assert.Equal(t, v2, "v2")
    28  }
    29  

View as plain text