Skip to content

Commit

Permalink
fix tests by adding .materialized() to remove the matview
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinJanuel committed Jun 19, 2024
1 parent 4ab2ec8 commit efb0a68
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions test/node/src/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1952,23 +1952,28 @@ for (const dialect of DIALECTS) {
describe('refresh materialized view', () => {
beforeEach(async () => {
await ctx.db.schema
.createView('dogs')
.createView('materialized_dogs')
.materialized()
.as(ctx.db.selectFrom('pet').selectAll().where('species', '=', 'dog'))
.execute()
})

afterEach(async () => {
await ctx.db.schema.dropView('dogs').ifExists().execute()
await ctx.db.schema
.dropView('materialized_dogs')
.materialized()
.ifExists()
.execute()
})

if (dialect === 'postgres') {
it('should refresh a materialized view', async () => {
const builder = ctx.db.schema.refreshMaterializedView('dogs')
const builder = ctx.db.schema
.refreshMaterializedView('materialized_dogs')

testSql(builder, dialect, {
postgres: {
sql: `refresh materialized view "dogs" with data`,
sql: `refresh materialized view "materialized_dogs" with data`,
parameters: [],
},
mssql: NOT_SUPPORTED,
Expand All @@ -1980,11 +1985,13 @@ for (const dialect of DIALECTS) {
})

it('should refresh a materialized view concurrently', async () => {
const builder = ctx.db.schema.refreshMaterializedView('dogs').concurrently()
const builder = ctx.db.schema
.refreshMaterializedView('materialized_dogs')
.concurrently()

testSql(builder, dialect, {
postgres: {
sql: `refresh materialized view concurrently "dogs" with data`,
sql: `refresh materialized view concurrently "materialized_dogs" with data`,
parameters: [],
},
mssql: NOT_SUPPORTED,
Expand All @@ -1996,11 +2003,13 @@ for (const dialect of DIALECTS) {
})

it('should refresh a materialized view with no data', async () => {
const builder = ctx.db.schema.refreshMaterializedView('dogs').withNoData()
const builder = ctx.db.schema
.refreshMaterializedView('materialized_dogs')
.withNoData()

testSql(builder, dialect, {
postgres: {
sql: `refresh materialized view "dogs" with no data`,
sql: `refresh materialized view "materialized_dogs" with no data`,
parameters: [],
},
mssql: NOT_SUPPORTED,
Expand Down

0 comments on commit efb0a68

Please sign in to comment.