Skip to content

Commit

Permalink
Qualify Role Name (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
dehume authored Jul 13, 2023
1 parent bfbe917 commit 983f219
Show file tree
Hide file tree
Showing 28 changed files with 80 additions and 72 deletions.
4 changes: 2 additions & 2 deletions integration/role.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
resource "materialize_role" "role_1" {
name = "role_1"
name = "role-1"
}

resource "materialize_role" "role_2" {
name = "role_2"
name = "role-2"
}

resource "materialize_grant_system_privilege" "role_1_system_createrole" {
Expand Down
16 changes: 12 additions & 4 deletions pkg/materialize/privilege.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,25 @@ func (i *PrivilegeObjectStruct) QualifiedName() string {
}

// DDL
type MaterializeRole struct {
name string
}

func (b *MaterializeRole) QualifiedName() string {
return QualifiedName(b.name)
}

type PrivilegeBuilder struct {
ddl Builder
role string
role MaterializeRole
privilege string
object PrivilegeObjectStruct
}

func NewPrivilegeBuilder(conn *sqlx.DB, role, privilege string, object PrivilegeObjectStruct) *PrivilegeBuilder {
return &PrivilegeBuilder{
ddl: Builder{conn, Privilege},
role: role,
role: MaterializeRole{name: role},
privilege: privilege,
object: object,
}
Expand All @@ -175,13 +183,13 @@ func objectCompatibility(objectType string) string {

func (b *PrivilegeBuilder) Grant() error {
t := objectCompatibility(b.object.Type)
q := fmt.Sprintf(`GRANT %s ON %s %s TO %s;`, b.privilege, t, b.object.QualifiedName(), b.role)
q := fmt.Sprintf(`GRANT %s ON %s %s TO %s;`, b.privilege, t, b.object.QualifiedName(), b.role.QualifiedName())
return b.ddl.exec(q)
}

func (b *PrivilegeBuilder) Revoke() error {
t := objectCompatibility(b.object.Type)
q := fmt.Sprintf(`REVOKE %s ON %s %s FROM %s;`, b.privilege, t, b.object.QualifiedName(), b.role)
q := fmt.Sprintf(`REVOKE %s ON %s %s FROM %s;`, b.privilege, t, b.object.QualifiedName(), b.role.QualifiedName())
return b.ddl.exec(q)
}

Expand Down
16 changes: 8 additions & 8 deletions pkg/materialize/privilege_default_privilege.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (

type DefaultPrivilegeBuilder struct {
ddl Builder
grantee string
grantee MaterializeRole
objectType string
privilege string
targetRole string
targetRole MaterializeRole
schemaName string
databaseName string
}
Expand All @@ -23,12 +23,12 @@ func NewDefaultPrivilegeBuilder(conn *sqlx.DB, objectType, grantee, privilege st
ddl: Builder{conn, Privilege},
objectType: objectType,
privilege: privilege,
grantee: grantee,
grantee: MaterializeRole{name: grantee},
}
}

func (b *DefaultPrivilegeBuilder) TargetRole(c string) *DefaultPrivilegeBuilder {
b.targetRole = c
b.targetRole = MaterializeRole{name: c}
return b
}

Expand All @@ -47,11 +47,11 @@ func (b *DefaultPrivilegeBuilder) baseQuery(action string) error {
q.WriteString(`ALTER DEFAULT PRIVILEGES`)

// role
if b.targetRole != "" && b.targetRole != "ALL" {
q.WriteString(fmt.Sprintf(` FOR ROLE %s`, b.targetRole))
if b.targetRole.name != "" && b.targetRole.name != "ALL" {
q.WriteString(fmt.Sprintf(` FOR ROLE %s`, b.targetRole.QualifiedName()))
}

if b.targetRole == "ALL" {
if b.targetRole.name == "ALL" {
q.WriteString(" FOR ALL ROLES")
}

Expand All @@ -71,7 +71,7 @@ func (b *DefaultPrivilegeBuilder) baseQuery(action string) error {
grantDirection = "FROM"
}

q.WriteString(fmt.Sprintf(` %[1]s %[2]s ON %[3]sS %[4]s %[5]s`, action, b.privilege, b.objectType, grantDirection, b.grantee))
q.WriteString(fmt.Sprintf(` %[1]s %[2]s ON %[3]sS %[4]s %[5]s`, action, b.privilege, b.objectType, grantDirection, b.grantee.QualifiedName()))

q.WriteString(`;`)
return b.ddl.exec(q.String())
Expand Down
8 changes: 4 additions & 4 deletions pkg/materialize/privilege_default_privilege_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestDefaultPrivilegeIdRoleQualified(t *testing.T) {

func TestDefaultPrivilegeGrantSimple(t *testing.T) {
testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
mock.ExpectExec(`ALTER DEFAULT PRIVILEGES GRANT SELECT ON TABLES TO joe;`).WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec(`ALTER DEFAULT PRIVILEGES GRANT SELECT ON TABLES TO "joe";`).WillReturnResult(sqlmock.NewResult(1, 1))

b := NewDefaultPrivilegeBuilder(db, "TABLE", "joe", "SELECT")
if err := b.Grant(); err != nil {
Expand All @@ -124,7 +124,7 @@ func TestDefaultPrivilegeGrantSimple(t *testing.T) {

func TestDefaultPrivilegeGrantComplex(t *testing.T) {
testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
mock.ExpectExec(`ALTER DEFAULT PRIVILEGES FOR ROLE interns IN DATABASE "dev" GRANT ALL PRIVILEGES ON TABLES TO intern_managers;`).WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec(`ALTER DEFAULT PRIVILEGES FOR ROLE "interns" IN DATABASE "dev" GRANT ALL PRIVILEGES ON TABLES TO "intern_managers";`).WillReturnResult(sqlmock.NewResult(1, 1))

b := NewDefaultPrivilegeBuilder(db, "TABLE", "intern_managers", "ALL PRIVILEGES")
b.TargetRole("interns")
Expand All @@ -137,7 +137,7 @@ func TestDefaultPrivilegeGrantComplex(t *testing.T) {

func TestDefaultPrivilegeRevokeSimple(t *testing.T) {
testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
mock.ExpectExec(`ALTER DEFAULT PRIVILEGES FOR ROLE developers REVOKE USAGE ON SECRETS FROM project_managers;`).WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec(`ALTER DEFAULT PRIVILEGES FOR ROLE "developers" REVOKE USAGE ON SECRETS FROM "project_managers";`).WillReturnResult(sqlmock.NewResult(1, 1))

b := NewDefaultPrivilegeBuilder(db, "SECRET", "project_managers", "USAGE")
b.TargetRole("developers")
Expand All @@ -149,7 +149,7 @@ func TestDefaultPrivilegeRevokeSimple(t *testing.T) {

func TestDefaultPrivilegeGrantAllRoles(t *testing.T) {
testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
mock.ExpectExec(`ALTER DEFAULT PRIVILEGES FOR ALL ROLES GRANT SELECT ON TABLES TO managers;`).WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec(`ALTER DEFAULT PRIVILEGES FOR ALL ROLES GRANT SELECT ON TABLES TO "managers";`).WillReturnResult(sqlmock.NewResult(1, 1))

b := NewDefaultPrivilegeBuilder(db, "TABLE", "managers", "SELECT")
b.TargetRole("ALL")
Expand Down
12 changes: 6 additions & 6 deletions pkg/materialize/privilege_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ import (

type RolePrivilegeBuilder struct {
ddl Builder
role string
member string
role MaterializeRole
member MaterializeRole
}

func NewRolePrivilegeBuilder(conn *sqlx.DB, role, member string) *RolePrivilegeBuilder {
return &RolePrivilegeBuilder{
ddl: Builder{conn, Privilege},
role: role,
member: member,
role: MaterializeRole{name: role},
member: MaterializeRole{name: member},
}
}

func (b *RolePrivilegeBuilder) Grant() error {
q := fmt.Sprintf(`GRANT %s TO %s;`, b.role, b.member)
q := fmt.Sprintf(`GRANT %s TO %s;`, b.role.QualifiedName(), b.member.QualifiedName())
return b.ddl.exec(q)
}

func (b *RolePrivilegeBuilder) Revoke() error {
q := fmt.Sprintf(`REVOKE %s FROM %s;`, b.role, b.member)
q := fmt.Sprintf(`REVOKE %s FROM %s;`, b.role.QualifiedName(), b.member.QualifiedName())
return b.ddl.exec(q)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/materialize/privilege_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestParseRolePrivileges(t *testing.T) {

func TestRolePrivilegeGrant(t *testing.T) {
testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
mock.ExpectExec(`GRANT dev_role TO user;`).WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec(`GRANT "dev_role" TO "user";`).WillReturnResult(sqlmock.NewResult(1, 1))

b := NewRolePrivilegeBuilder(db, "dev_role", "user")
if err := b.Grant(); err != nil {
Expand All @@ -54,7 +54,7 @@ func TestRolePrivilegeGrant(t *testing.T) {

func TestRolePrivilegeRevoke(t *testing.T) {
testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
mock.ExpectExec(`REVOKE dev_role FROM user;`).WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec(`REVOKE "dev_role" FROM "user";`).WillReturnResult(sqlmock.NewResult(1, 1))

b := NewRolePrivilegeBuilder(db, "dev_role", "user")
if err := b.Revoke(); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/materialize/privilege_system_privilege.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ import (

type SystemPrivilegeBuilder struct {
ddl Builder
role string
role MaterializeRole
privilege string
}

func NewSystemPrivilegeBuilder(conn *sqlx.DB, role, privilege string) *SystemPrivilegeBuilder {
return &SystemPrivilegeBuilder{
ddl: Builder{conn, Privilege},
role: role,
role: MaterializeRole{name: role},
privilege: privilege,
}
}

func (b *SystemPrivilegeBuilder) Grant() error {
q := fmt.Sprintf(`GRANT %s ON SYSTEM TO %s;`, b.privilege, b.role)
q := fmt.Sprintf(`GRANT %s ON SYSTEM TO %s;`, b.privilege, b.role.QualifiedName())
return b.ddl.exec(q)
}

func (b *SystemPrivilegeBuilder) Revoke() error {
q := fmt.Sprintf(`REVOKE %s ON SYSTEM FROM %s;`, b.privilege, b.role)
q := fmt.Sprintf(`REVOKE %s ON SYSTEM FROM %s;`, b.privilege, b.role.QualifiedName())
return b.ddl.exec(q)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/materialize/privilege_system_privilege_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestParseSystemPrivileges(t *testing.T) {

func TestSystemPrivilegeGrant(t *testing.T) {
testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
mock.ExpectExec(`GRANT CREATEDB ON SYSTEM TO joe;`).WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec(`GRANT CREATEDB ON SYSTEM TO "joe";`).WillReturnResult(sqlmock.NewResult(1, 1))

b := NewSystemPrivilegeBuilder(db, "joe", "CREATEDB")
if err := b.Grant(); err != nil {
Expand All @@ -44,7 +44,7 @@ func TestSystemPrivilegeGrant(t *testing.T) {

func TestSystemPrivilegeRevoke(t *testing.T) {
testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
mock.ExpectExec(`REVOKE CREATEDB ON SYSTEM FROM joe;`).WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec(`REVOKE CREATEDB ON SYSTEM FROM "joe";`).WillReturnResult(sqlmock.NewResult(1, 1))

b := NewSystemPrivilegeBuilder(db, "joe", "CREATEDB")
if err := b.Revoke(); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/materialize/privilege_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestObjectCompatibility(t *testing.T) {

func TestPrivilegeGrant(t *testing.T) {
testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
mock.ExpectExec(`GRANT CREATE ON DATABASE "materialize" TO joe;`).WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec(`GRANT CREATE ON DATABASE "materialize" TO "joe";`).WillReturnResult(sqlmock.NewResult(1, 1))

b := NewPrivilegeBuilder(db, "joe", "CREATE", PrivilegeObjectStruct{Type: "DATABASE", Name: "materialize"})
if err := b.Grant(); err != nil {
Expand All @@ -56,7 +56,7 @@ func TestPrivilegeGrant(t *testing.T) {

func TestPrivilegeRevoke(t *testing.T) {
testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
mock.ExpectExec(`REVOKE CREATE ON DATABASE "materialize" FROM joe;`).WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec(`REVOKE CREATE ON DATABASE "materialize" FROM "joe";`).WillReturnResult(sqlmock.NewResult(1, 1))

b := NewPrivilegeBuilder(db, "joe", "CREATE", PrivilegeObjectStruct{Type: "DATABASE", Name: "materialize"})
if err := b.Revoke(); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestResourceGrantClusterDefaultPrivilegeCreate(t *testing.T) {
testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
// Create
mock.ExpectExec(
`ALTER DEFAULT PRIVILEGES FOR ROLE developers GRANT USAGE ON CLUSTERS TO project_managers;`,
`ALTER DEFAULT PRIVILEGES FOR ROLE "developers" GRANT USAGE ON CLUSTERS TO "project_managers";`,
).WillReturnResult(sqlmock.NewResult(1, 1))

// DefaultPrivilegeId - Query grantee role
Expand Down Expand Up @@ -65,7 +65,7 @@ func TestResourceGrantClusterDefaultPrivilegeDelete(t *testing.T) {
r.NotNil(d)

testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
mock.ExpectExec(`ALTER DEFAULT PRIVILEGES FOR ROLE developers REVOKE USAGE ON CLUSTERS FROM project_managers;`).WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec(`ALTER DEFAULT PRIVILEGES FOR ROLE "developers" REVOKE USAGE ON CLUSTERS FROM "project_managers";`).WillReturnResult(sqlmock.NewResult(1, 1))

if err := grantClusterDefaultPrivilegeDelete(context.TODO(), d, db); err != nil {
t.Fatal(err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/resources/resource_grant_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestResourceGrantClusterCreate(t *testing.T) {
testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
// Create
mock.ExpectExec(
`GRANT CREATE ON CLUSTER "materialize" TO joe;`,
`GRANT CREATE ON CLUSTER "materialize" TO "joe";`,
).WillReturnResult(sqlmock.NewResult(1, 1))

// Query Role Id
Expand Down Expand Up @@ -62,7 +62,7 @@ func TestResourceGrantClusterDelete(t *testing.T) {
r.NotNil(d)

testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
mock.ExpectExec(`REVOKE CREATE ON CLUSTER "materialize" FROM joe;`).WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec(`REVOKE CREATE ON CLUSTER "materialize" FROM "joe";`).WillReturnResult(sqlmock.NewResult(1, 1))

if err := grantClusterDelete(context.TODO(), d, db); err != nil {
t.Fatal(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestResourceGrantConnectionDefaultPrivilegeCreate(t *testing.T) {
testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
// Create
mock.ExpectExec(
`ALTER DEFAULT PRIVILEGES FOR ROLE developers GRANT USAGE ON CONNECTIONS TO project_managers;`,
`ALTER DEFAULT PRIVILEGES FOR ROLE "developers" GRANT USAGE ON CONNECTIONS TO "project_managers";`,
).WillReturnResult(sqlmock.NewResult(1, 1))

// DefaultPrivilegeId - Query grantee role
Expand Down Expand Up @@ -65,7 +65,7 @@ func TestResourceGrantConnectionDefaultPrivilegeDelete(t *testing.T) {
r.NotNil(d)

testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
mock.ExpectExec(`ALTER DEFAULT PRIVILEGES FOR ROLE developers REVOKE USAGE ON CONNECTIONS FROM project_managers;`).WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec(`ALTER DEFAULT PRIVILEGES FOR ROLE "developers" REVOKE USAGE ON CONNECTIONS FROM "project_managers";`).WillReturnResult(sqlmock.NewResult(1, 1))

if err := grantConnectionDefaultPrivilegeDelete(context.TODO(), d, db); err != nil {
t.Fatal(err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/resources/resource_grant_connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestResourceGrantConnectionCreate(t *testing.T) {
testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
// Create
mock.ExpectExec(
`GRANT USAGE ON CONNECTION "database"."schema"."conn" TO joe;`,
`GRANT USAGE ON CONNECTION "database"."schema"."conn" TO "joe";`,
).WillReturnResult(sqlmock.NewResult(1, 1))

// Query Role Id
Expand Down Expand Up @@ -66,7 +66,7 @@ func TestResourceGrantConnectionDelete(t *testing.T) {
r.NotNil(d)

testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
mock.ExpectExec(`REVOKE USAGE ON CONNECTION "database"."schema"."conn" FROM joe;`).WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec(`REVOKE USAGE ON CONNECTION "database"."schema"."conn" FROM "joe";`).WillReturnResult(sqlmock.NewResult(1, 1))

if err := grantConnectionDelete(context.TODO(), d, db); err != nil {
t.Fatal(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestResourceGrantDatabaseDefaultPrivilegeCreate(t *testing.T) {
testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
// Create
mock.ExpectExec(
`ALTER DEFAULT PRIVILEGES FOR ROLE developers GRANT USAGE ON DATABASES TO project_managers;`,
`ALTER DEFAULT PRIVILEGES FOR ROLE "developers" GRANT USAGE ON DATABASES TO "project_managers";`,
).WillReturnResult(sqlmock.NewResult(1, 1))

// DefaultPrivilegeId - Query grantee role
Expand Down Expand Up @@ -65,7 +65,7 @@ func TestResourceGrantDatabaseDefaultPrivilegeDelete(t *testing.T) {
r.NotNil(d)

testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
mock.ExpectExec(`ALTER DEFAULT PRIVILEGES FOR ROLE developers REVOKE USAGE ON DATABASES FROM project_managers;`).WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec(`ALTER DEFAULT PRIVILEGES FOR ROLE "developers" REVOKE USAGE ON DATABASES FROM "project_managers";`).WillReturnResult(sqlmock.NewResult(1, 1))

if err := grantDatabaseDefaultPrivilegeDelete(context.TODO(), d, db); err != nil {
t.Fatal(err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/resources/resource_grant_database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestResourceGrantDatabaseCreate(t *testing.T) {
testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
// Create
mock.ExpectExec(
`GRANT CREATE ON DATABASE "materialize" TO joe;`,
`GRANT CREATE ON DATABASE "materialize" TO "joe";`,
).WillReturnResult(sqlmock.NewResult(1, 1))

// Query Role Id
Expand Down Expand Up @@ -62,7 +62,7 @@ func TestResourceGrantDatabaseDelete(t *testing.T) {
r.NotNil(d)

testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
mock.ExpectExec(`REVOKE CREATE ON DATABASE "materialize" FROM joe;`).WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec(`REVOKE CREATE ON DATABASE "materialize" FROM "joe";`).WillReturnResult(sqlmock.NewResult(1, 1))

if err := grantDatabaseDelete(context.TODO(), d, db); err != nil {
t.Fatal(err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/resources/resource_grant_materialized_view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestResourceGrantMaterializedViewCreate(t *testing.T) {
testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
// Create
mock.ExpectExec(
`GRANT SELECT ON TABLE "database"."schema"."mview" TO joe;`,
`GRANT SELECT ON TABLE "database"."schema"."mview" TO "joe";`,
).WillReturnResult(sqlmock.NewResult(1, 1))

// Query Role Id
Expand Down Expand Up @@ -66,7 +66,7 @@ func TestResourceGrantMaterializedViewDelete(t *testing.T) {
r.NotNil(d)

testhelpers.WithMockDb(t, func(db *sqlx.DB, mock sqlmock.Sqlmock) {
mock.ExpectExec(`REVOKE SELECT ON TABLE "database"."schema"."mview" FROM joe;`).WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec(`REVOKE SELECT ON TABLE "database"."schema"."mview" FROM "joe";`).WillReturnResult(sqlmock.NewResult(1, 1))

if err := grantMaterializedViewDelete(context.TODO(), d, db); err != nil {
t.Fatal(err)
Expand Down
Loading

0 comments on commit 983f219

Please sign in to comment.