github.com/openfga/openfga@v1.5.4-rc1/pkg/telemetry/context_test.go (about) 1 package telemetry 2 3 import ( 4 "context" 5 "testing" 6 7 openfgav1 "github.com/openfga/api/proto/openfga/v1" 8 "github.com/stretchr/testify/require" 9 ) 10 11 func TestKnownRPCInfo(t *testing.T) { 12 rpcInfo := RPCInfo{ 13 Method: "check", 14 Service: openfgav1.OpenFGAService_ServiceDesc.ServiceName, 15 } 16 ctx := ContextWithRPCInfo(context.Background(), rpcInfo) 17 18 output := RPCInfoFromContext(ctx) 19 require.Equal(t, rpcInfo, output) 20 } 21 22 func TestUnknownRPCInfo(t *testing.T) { 23 output := RPCInfoFromContext(context.Background()) 24 require.Equal(t, RPCInfo{ 25 Method: "unknown", 26 Service: "unknown", 27 }, output) 28 }