trpc.group/trpc-go/trpc-go@v1.0.3/internal/context/value_ctx_test.go (about) 1 package context_test 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/stretchr/testify/require" 8 icontext "trpc.group/trpc-go/trpc-go/internal/context" 9 ) 10 11 func TestWithValues(t *testing.T) { 12 type testKey struct{} 13 testValue := "value" 14 ctx := context.WithValue(context.TODO(), testKey{}, testValue) 15 ctx1 := icontext.NewContextWithValues(context.TODO(), ctx) 16 require.NotNil(t, ctx1.Value(testKey{})) 17 type notExist struct{} 18 require.Nil(t, ctx1.Value(notExist{})) 19 }