...

Source file src/github.com/opentracing/opentracing-go/options_test.go

Documentation: github.com/opentracing/opentracing-go

     1  package opentracing
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  )
     8  
     9  func TestChildOfAndFollowsFrom(t *testing.T) {
    10  	tests := []struct {
    11  		newOpt  func(SpanContext) SpanReference
    12  		refType SpanReferenceType
    13  		name    string
    14  	}{
    15  		{ChildOf, ChildOfRef, "ChildOf"},
    16  		{FollowsFrom, FollowsFromRef, "FollowsFrom"},
    17  	}
    18  
    19  	for _, test := range tests {
    20  		opts := new(StartSpanOptions)
    21  
    22  		test.newOpt(nil).Apply(opts)
    23  		require.Nil(t, opts.References, "%s(nil) must not append a reference", test.name)
    24  
    25  		ctx := new(noopSpanContext)
    26  		test.newOpt(ctx).Apply(opts)
    27  		require.Equal(t, []SpanReference{
    28  			SpanReference{ReferencedContext: ctx, Type: test.refType},
    29  		}, opts.References, "%s(ctx) must append a reference", test.name)
    30  	}
    31  }
    32  

View as plain text