package logid

// FIXME(iven): Move logid to message header
// import (
// 	"context"
// 	"testing"
//
// 	. "github.com/smartystreets/goconvey/convey"
// 	"github.com/tidbcloud/idl/pbgen/proto/base"
// )
//
// type ReqWithBaseReq struct {
// 	BaseReq *base.BaseReq
// 	Foo     string `protobuf:"bytes,2,opt,name=foo,proto3" json:"foo,omitempty"`
// }
//
// type ReqWithoutBaseReq struct {
// 	Foo string `protobuf:"bytes,2,opt,name=foo,proto3" json:"foo,omitempty"`
// }
//
// func Test_injectCtxInfoIntoReq(t *testing.T) {
// 	Convey("Test_injectCtxInfoIntoReq", t, func() {
// 		ctx := context.Background()
// 		requestid := GenLogid()
// 		ctx = WithLogid(ctx, requestid)
// 		reqWithBaseReq := &ReqWithBaseReq{
// 			BaseReq: &base.BaseReq{Tags: map[string]string{}},
// 		}
// 		reqWithoutBaseReq := &ReqWithoutBaseReq{}
//
// 		Convey("should inject ctx info into req when all is well", func() {
// 			injectCtxInfoIntoReq(ctx, reqWithBaseReq)
// 			So(reqWithBaseReq.BaseReq.Tags[GRPCHeaderKey], ShouldEqual, requestid)
// 		})
// 		Convey("should inject ctx info into req when req.BaseReq.Tags is nil", func() {
// 			reqWithBaseReq.BaseReq.Tags = nil
// 			injectCtxInfoIntoReq(ctx, reqWithBaseReq)
// 			So(reqWithBaseReq.BaseReq.Tags[GRPCHeaderKey], ShouldEqual, requestid)
// 		})
// 		Convey("should do nothing when req is nil", func() {
// 			injectCtxInfoIntoReq(ctx, nil)
// 		})
// 		Convey("should do nothing when req don't have the BaseReq filed", func() {
// 			injectCtxInfoIntoReq(ctx, reqWithoutBaseReq)
// 		})
// 	})
// }
//
// func Test_injectCtxInfoIntoCtx(t *testing.T) {
// 	Convey("Test_injectCtxInfoIntoCtx", t, func() {
// 		ctx := context.Background()
// 		requestid := GenLogid()
// 		reqWithBaseReq := &ReqWithBaseReq{
// 			BaseReq: &base.BaseReq{Tags: map[string]string{
// 				GRPCHeaderKey: requestid,
// 			}},
// 		}
// 		reqWithoutBaseReq := &ReqWithoutBaseReq{}
//
// 		Convey("should inject ctx info into ctx when all is well", func() {
// 			r1 := injectCtxInfoIntoCtx(ctx, reqWithBaseReq)
// 			So(GetLogid(r1), ShouldEqual, requestid)
// 		})
// 		Convey("should do nothing when req is nil", func() {
// 			r1 := injectCtxInfoIntoCtx(ctx, nil)
// 			So(r1, ShouldEqual, ctx)
// 		})
// 		Convey("should do nothing when req don't have the BaseReq filed", func() {
// 			r1 := injectCtxInfoIntoCtx(ctx, reqWithoutBaseReq)
// 			So(r1, ShouldEqual, ctx)
// 		})
// 	})
// }
