File: options_test.go

package info (click to toggle)
golang-github-opentracing-opentracing-go 1.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-backports, bookworm-proposed-updates, forky, sid, trixie
  • size: 268 kB
  • sloc: makefile: 18
file content (31 lines) | stat: -rw-r--r-- 742 bytes parent folder | download | duplicates (3)
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
package opentracing

import (
	"testing"

	"github.com/stretchr/testify/require"
)

func TestChildOfAndFollowsFrom(t *testing.T) {
	tests := []struct {
		newOpt  func(SpanContext) SpanReference
		refType SpanReferenceType
		name    string
	}{
		{ChildOf, ChildOfRef, "ChildOf"},
		{FollowsFrom, FollowsFromRef, "FollowsFrom"},
	}

	for _, test := range tests {
		opts := new(StartSpanOptions)

		test.newOpt(nil).Apply(opts)
		require.Nil(t, opts.References, "%s(nil) must not append a reference", test.name)

		ctx := new(noopSpanContext)
		test.newOpt(ctx).Apply(opts)
		require.Equal(t, []SpanReference{
			SpanReference{ReferencedContext: ctx, Type: test.refType},
		}, opts.References, "%s(ctx) must append a reference", test.name)
	}
}