@@ -41,7 +41,10 @@ func TestCreateModuleRole_NoDescription(t *testing.T) {
4141 }
4242 return
4343 }
44- stmt := prog .Statements [0 ].(* ast.CreateModuleRoleStmt )
44+ stmt , ok := prog .Statements [0 ].(* ast.CreateModuleRoleStmt )
45+ if ! ok {
46+ t .Fatalf ("Expected CreateModuleRoleStmt, got %T" , prog .Statements [0 ])
47+ }
4548 if stmt .Description != "" {
4649 t .Errorf ("Expected empty description, got %q" , stmt .Description )
4750 }
@@ -104,7 +107,10 @@ func TestCreateUserRole_OrModify(t *testing.T) {
104107 }
105108 return
106109 }
107- stmt := prog .Statements [0 ].(* ast.CreateUserRoleStmt )
110+ stmt , ok := prog .Statements [0 ].(* ast.CreateUserRoleStmt )
111+ if ! ok {
112+ t .Fatalf ("Expected CreateUserRoleStmt, got %T" , prog .Statements [0 ])
113+ }
108114 if ! stmt .CreateOrModify {
109115 t .Error ("Expected CreateOrModify true" )
110116 }
@@ -146,7 +152,10 @@ func TestAlterUserRole_Remove(t *testing.T) {
146152 }
147153 return
148154 }
149- stmt := prog .Statements [0 ].(* ast.AlterUserRoleStmt )
155+ stmt , ok := prog .Statements [0 ].(* ast.AlterUserRoleStmt )
156+ if ! ok {
157+ t .Fatalf ("Expected AlterUserRoleStmt, got %T" , prog .Statements [0 ])
158+ }
150159 if stmt .Add {
151160 t .Error ("Expected Add false" )
152161 }
@@ -229,7 +238,10 @@ func TestGrantEntityAccess_MultipleRoles(t *testing.T) {
229238 }
230239 return
231240 }
232- stmt := prog .Statements [0 ].(* ast.GrantEntityAccessStmt )
241+ stmt , ok := prog .Statements [0 ].(* ast.GrantEntityAccessStmt )
242+ if ! ok {
243+ t .Fatalf ("Expected GrantEntityAccessStmt, got %T" , prog .Statements [0 ])
244+ }
233245 if len (stmt .Roles ) != 2 {
234246 t .Fatalf ("Expected 2 roles, got %d" , len (stmt .Roles ))
235247 }
@@ -265,7 +277,10 @@ func TestRevokeEntityAccess_Partial(t *testing.T) {
265277 }
266278 return
267279 }
268- stmt := prog .Statements [0 ].(* ast.RevokeEntityAccessStmt )
280+ stmt , ok := prog .Statements [0 ].(* ast.RevokeEntityAccessStmt )
281+ if ! ok {
282+ t .Fatalf ("Expected RevokeEntityAccessStmt, got %T" , prog .Statements [0 ])
283+ }
269284 if len (stmt .Rights ) != 1 {
270285 t .Fatalf ("Expected 1 right, got %d" , len (stmt .Rights ))
271286 }
@@ -500,7 +515,10 @@ func TestAlterProjectSecurity_DemoUsers(t *testing.T) {
500515 }
501516 return
502517 }
503- stmt := prog .Statements [0 ].(* ast.AlterProjectSecurityStmt )
518+ stmt , ok := prog .Statements [0 ].(* ast.AlterProjectSecurityStmt )
519+ if ! ok {
520+ t .Fatalf ("Expected AlterProjectSecurityStmt, got %T" , prog .Statements [0 ])
521+ }
504522 if stmt .SecurityLevel != "" {
505523 t .Errorf ("Expected empty security level, got %q" , stmt .SecurityLevel )
506524 }
@@ -545,7 +563,10 @@ func TestCreateDemoUser_OrModify(t *testing.T) {
545563 }
546564 return
547565 }
548- stmt := prog .Statements [0 ].(* ast.CreateDemoUserStmt )
566+ stmt , ok := prog .Statements [0 ].(* ast.CreateDemoUserStmt )
567+ if ! ok {
568+ t .Fatalf ("Expected CreateDemoUserStmt, got %T" , prog .Statements [0 ])
569+ }
549570 if ! stmt .CreateOrModify {
550571 t .Error ("Expected CreateOrModify true" )
551572 }
@@ -596,7 +617,10 @@ func TestUpdateSecurity_InModule(t *testing.T) {
596617 }
597618 return
598619 }
599- stmt := prog .Statements [0 ].(* ast.UpdateSecurityStmt )
620+ stmt , ok := prog .Statements [0 ].(* ast.UpdateSecurityStmt )
621+ if ! ok {
622+ t .Fatalf ("Expected UpdateSecurityStmt, got %T" , prog .Statements [0 ])
623+ }
600624 if stmt .Module != "MyModule" {
601625 t .Errorf ("Expected MyModule, got %q" , stmt .Module )
602626 }
0 commit comments