Skip to content

Commit

Permalink
add ut and bvt cases for udf
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisxu333 committed Dec 20, 2022
1 parent d648990 commit 73cae81
Show file tree
Hide file tree
Showing 7 changed files with 7,034 additions and 6,454 deletions.
54 changes: 54 additions & 0 deletions pkg/frontend/authenticate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,39 @@ func Test_checkUserExistsOrNot(t *testing.T) {
})
}

func Test_initFunction(t *testing.T) {
convey.Convey("init function", t, func() {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

pu := config.NewParameterUnit(&config.FrontendParameters{}, nil, nil, nil, nil)
pu.SV.SetDefaultValues()

ctx := context.WithValue(context.TODO(), config.ParameterUnitKey, pu)

cu := &tree.CreateFunction{
Name: tree.NewFuncName("testFunc"),
Args: nil,
ReturnType: tree.NewReturnType("int"),
Body: "",
Language: "sql",
}

tenant := &TenantInfo{
Tenant: sysAccountName,
User: rootName,
DefaultRole: moAdminRoleName,
TenantID: sysAccountID,
UserID: rootID,
DefaultRoleID: moAdminRoleID,
}

ses := &Session{}
err := InitFunction(ctx, ses, tenant, cu)
convey.So(err, convey.ShouldBeNil)
})
}

func Test_initUser(t *testing.T) {
convey.Convey("init user", t, func() {
ctrl := gomock.NewController(t)
Expand Down Expand Up @@ -5452,6 +5485,27 @@ func Test_doRevokePrivilege(t *testing.T) {
})
}

func Test_doDropFunction(t *testing.T) {
convey.Convey("drop function", t, func() {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

pu := config.NewParameterUnit(&config.FrontendParameters{}, nil, nil, nil, nil)
pu.SV.SetDefaultValues()

ctx := context.WithValue(context.TODO(), config.ParameterUnitKey, pu)

cu := &tree.DropFunction{
Name: tree.NewFuncName("testFunc"),
Args: nil,
}

ses := &Session{}
err := doDropFunction(ctx, ses, cu)
convey.So(err, convey.ShouldBeNil)
})
}

func Test_doDropRole(t *testing.T) {
convey.Convey("drop role succ", t, func() {
ctrl := gomock.NewController(t)
Expand Down
Loading

0 comments on commit 73cae81

Please sign in to comment.