Debian Codegraph @

instrumentation/net/http/otelhttp/start_time_context_test.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package otelhttp
5
6 import (
7 "testing"
8 "time"
9
10 "github.com/stretchr/testify/assert"
11 )
12
13 func TestStartTimeFromContext(t *testing.T) {
14 ctx := t.Context()
15 startTime := StartTimeFromContext(ctx)
16 assert.True(t, startTime.IsZero())
17
18 now := time.Now()
19 ctx = ContextWithStartTime(ctx, now)
20 startTime = StartTimeFromContext(ctx)
21 assert.True(t, startTime.Equal(now))
22 }