MCPcopy
hub / github.com/pingcap/tidb / getEvalCtxOptionsForTest

Function getEvalCtxOptionsForTest

pkg/expression/exprstatic/evalctx_test.go:88–127  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

86}
87
88func 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
129func checkOptionsStaticEvalCtx(t *testing.T, ctx *EvalContext, s *evalCtxOptionsTestState) {
130 require.Same(t, ctx.warnHandler, s.warnHandler)

Callers 2

TestNewStaticEvalCtxFunction · 0.85

Calls 15

NewUserVarsFunction · 0.92
CurrentUserPropProviderFuncType · 0.92
DDLOwnerInfoProviderFuncType · 0.92
WithWarnHandlerFunction · 0.85
WithSQLModeFunction · 0.85
WithTypeFlagsFunction · 0.85
WithErrLevelMapFunction · 0.85
WithLocationFunction · 0.85
WithCurrentDBFunction · 0.85
WithCurrentTimeFunction · 0.85
WithMaxAllowedPacketFunction · 0.85

Tested by

no test coverage detected