Skip to content

Commit

Permalink
chore: cleanup of unit tests pt 2
Browse files Browse the repository at this point in the history
Signed-off-by: Jaime Silvela <[email protected]>
  • Loading branch information
jsilvela committed Oct 24, 2024
1 parent 3376c47 commit 848a03c
Show file tree
Hide file tree
Showing 2 changed files with 154 additions and 249 deletions.
21 changes: 11 additions & 10 deletions internal/management/controller/roles/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ import (
)

const (
expectedSelStmt = `SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb,
rolcanlogin, rolreplication, rolconnlimit, rolpassword, rolvaliduntil, rolbypassrls,
pg_catalog.shobj_description(auth.oid, 'pg_authid') as comment, auth.xmin,
mem.inroles
FROM pg_catalog.pg_authid as auth
LEFT JOIN (
SELECT array_agg(pg_get_userbyid(roleid)) as inroles, member
FROM pg_auth_members GROUP BY member
) mem ON member = oid
WHERE rolname not like 'pg\_%'`

expectedMembershipStmt = `SELECT mem.inroles
FROM pg_catalog.pg_authid as auth
LEFT JOIN (
Expand Down Expand Up @@ -146,16 +157,6 @@ var _ = Describe("Postgres RoleManager implementation test", func() {
"ALTER ROLE \"%s\" BYPASSRLS NOCREATEDB CREATEROLE NOINHERIT LOGIN NOREPLICATION NOSUPERUSER CONNECTION LIMIT 2 ",
wantedRole.Name)
unWantedRoleExpectedDelStmt := fmt.Sprintf("DROP ROLE \"%s\"", unWantedRole.Name)
expectedSelStmt := `SELECT rolname, rolsuper, rolinherit, rolcreaterole, rolcreatedb,
rolcanlogin, rolreplication, rolconnlimit, rolpassword, rolvaliduntil, rolbypassrls,
pg_catalog.shobj_description(auth.oid, 'pg_authid') as comment, auth.xmin,
mem.inroles
FROM pg_catalog.pg_authid as auth
LEFT JOIN (
SELECT array_agg(pg_get_userbyid(roleid)) as inroles, member
FROM pg_auth_members GROUP BY member
) mem ON member = oid
WHERE rolname not like 'pg\_%'`

// Testing List
It("List can read the list of roles from the DB", func(ctx context.Context) {
Expand Down
Loading

0 comments on commit 848a03c

Please sign in to comment.