File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * clean.test.ts - clean test databases
3+ */
4+
5+ import { describe , it } from '@jest/globals'
6+ import { getChinookDatabase } from './shared'
7+
8+ describe . skip ( 'clean test suite' , ( ) => {
9+ it ( 'should remove test databases from the project' , async ( ) => {
10+ let chinook
11+ try {
12+ chinook = getChinookDatabase ( )
13+ // Use the connect utility to execute SQL statements on the selected database
14+ const result = await chinook . sql ( `LIST DATABASES` )
15+ const limit = 1000
16+ let removed = [ ]
17+ let dbname = ''
18+ for ( let i = 0 ; i < result . length ; i ++ ) {
19+ dbname = result [ i ] . name
20+ if ( ( dbname . startsWith ( '1brc' ) && dbname . includes ( '-2025' ) ) || dbname . startsWith ( 'testing-2025' ) ) {
21+ removed . push ( dbname )
22+ // console.log("remove ${dbname}")
23+ const r = await chinook . sql ( `REMOVE DATABASE ${ dbname } ` )
24+ if ( removed . length >= limit ) {
25+ break
26+ }
27+ }
28+ }
29+
30+ // Build the object to be returned by your edge function
31+ const message = `Number of databases: ${ result . length } , removed ${ removed . length } `
32+
33+ // Return the object from your edge function
34+
35+ console . debug ( { message, removed } )
36+ } finally {
37+ chinook ?. close ( )
38+ }
39+ } )
40+ } )
You can’t perform that action at this time.
0 commit comments