(t *testing.T)
| 86 | } |
| 87 | |
| 88 | func getEvalCtxOptionsForTest(t *testing.T) ([]EvalCtxOption, *evalCtxOptionsTestState) { |
| 89 | loc, err := time.LoadLocation("US/Eastern") |
| 90 | require.NoError(t, err) |
| 91 | s := &evalCtxOptionsTestState{ |
| 92 | now: time.Now(), |
| 93 | loc: loc, |
| 94 | warnHandler: contextutil.NewStaticWarnHandler(8), |
| 95 | userVars: variable.NewUserVars(), |
| 96 | } |
| 97 | |
| 98 | provider1 := expropt.CurrentUserPropProvider(func() (*auth.UserIdentity, []*auth.RoleIdentity) { |
| 99 | return &auth.UserIdentity{Username: "user1", Hostname: "host1"}, |
| 100 | []*auth.RoleIdentity{{Username: "role1", Hostname: "host2"}} |
| 101 | }) |
| 102 | |
| 103 | provider2 := expropt.DDLOwnerInfoProvider(func() bool { |
| 104 | return s.ddlOwner |
| 105 | }) |
| 106 | |
| 107 | return []EvalCtxOption{ |
| 108 | WithWarnHandler(s.warnHandler), |
| 109 | WithSQLMode(mysql.ModeNoZeroDate | mysql.ModeStrictTransTables), |
| 110 | WithTypeFlags(types.FlagAllowNegativeToUnsigned | types.FlagSkipASCIICheck), |
| 111 | WithErrLevelMap(errctx.LevelMap{ |
| 112 | errctx.ErrGroupBadNull: errctx.LevelError, |
| 113 | errctx.ErrGroupNoDefault: errctx.LevelError, |
| 114 | errctx.ErrGroupDividedByZero: errctx.LevelWarn, |
| 115 | }), |
| 116 | WithLocation(loc), |
| 117 | WithCurrentDB("db1"), |
| 118 | WithCurrentTime(func() (time.Time, error) { |
| 119 | return s.now, nil |
| 120 | }), |
| 121 | WithMaxAllowedPacket(12345), |
| 122 | WithDefaultWeekFormatMode("3"), |
| 123 | WithDivPrecisionIncrement(5), |
| 124 | WithUserVarsReader(s.userVars), |
| 125 | WithOptionalProperty(provider1, provider2), |
| 126 | }, s |
| 127 | } |
| 128 | |
| 129 | func checkOptionsStaticEvalCtx(t *testing.T, ctx *EvalContext, s *evalCtxOptionsTestState) { |
| 130 | require.Same(t, ctx.warnHandler, s.warnHandler) |
no test coverage detected