Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit 70771ba

Browse files
committed
Fix tests
1 parent d0d2aa5 commit 70771ba

File tree

5 files changed

+29
-15
lines changed

5 files changed

+29
-15
lines changed

src/main/groovy/org/grails/plugins/databasemigration/liquibase/GormDatabase.groovy

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ package org.grails.plugins.databasemigration.liquibase
1717

1818
import groovy.transform.CompileStatic
1919
import liquibase.database.DatabaseConnection
20+
import liquibase.database.OfflineConnection
2021
import liquibase.exception.DatabaseException
2122
import liquibase.ext.hibernate.database.HibernateDatabase
23+
import liquibase.snapshot.DatabaseSnapshot
24+
import liquibase.snapshot.JdbcDatabaseSnapshot
25+
import liquibase.snapshot.SnapshotControl
26+
import liquibase.structure.DatabaseObject
2227
import org.hibernate.boot.Metadata
2328
import org.hibernate.boot.MetadataSources
2429
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder
@@ -33,13 +38,22 @@ class GormDatabase extends HibernateDatabase {
3338

3439
private Dialect dialect
3540
private Metadata metadata
41+
DatabaseConnection connection
3642

3743
GormDatabase() {
3844
}
3945

4046
GormDatabase(Dialect dialect, ServiceRegistry serviceRegistry) {
4147
this.dialect = dialect
42-
this.metadata = new MetadataSources(serviceRegistry).getMetadataBuilder().build();
48+
this.metadata = new MetadataSources(serviceRegistry).getMetadataBuilder().build()
49+
SnapshotControl snapshotControl = new SnapshotControl(this, null, null)
50+
GormDatabase database = this
51+
OfflineConnection connection = new OfflineConnection("offline:gorm", null) {
52+
DatabaseSnapshot getSnapshot(DatabaseObject[] examples) {
53+
new JdbcDatabaseSnapshot(examples, database, snapshotControl)
54+
}
55+
}
56+
this.connection = connection
4357
}
4458

4559
@Override

src/test/groovy/org/grails/plugins/databasemigration/command/DbmDiffCommandSpec.groovy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ databaseChangeLog = \\{
5858
5959
changeSet\\(author: ".+?", id: ".+?"\\) \\{
6060
createTable\\(tableName: "AUTHOR"\\) \\{
61-
column\\(autoIncrement: "true", name: "ID", type: "INT\\(10\\)"\\) \\{
61+
column\\(autoIncrement: "true", name: "ID", type: "INT"\\) \\{
6262
constraints\\(primaryKey: "true", primaryKeyName: "PK_AUTHOR"\\)
6363
\\}
6464
@@ -70,7 +70,7 @@ databaseChangeLog = \\{
7070
7171
changeSet\\(author: ".+?", id: ".+?"\\) \\{
7272
addColumn\\(tableName: "BOOK"\\) \\{
73-
column\\(name: "PRICE", type: "INTEGER\\(10\\)"\\) \\{
73+
column\\(name: "PRICE", type: "INTEGER"\\) \\{
7474
constraints\\(nullable: "false"\\)
7575
\\}
7676
\\}
@@ -92,7 +92,7 @@ databaseChangeLog = \\{
9292
9393
changeSet\\(author: ".+?", id: ".+?"\\) \\{
9494
createTable\\(tableName: "AUTHOR"\\) \\{
95-
column\\(autoIncrement: "true", name: "ID", type: "INT\\(10\\)"\\) \\{
95+
column\\(autoIncrement: "true", name: "ID", type: "INT"\\) \\{
9696
constraints\\(primaryKey: "true", primaryKeyName: "PK_AUTHOR"\\)
9797
\\}
9898
@@ -104,7 +104,7 @@ databaseChangeLog = \\{
104104
105105
changeSet\\(author: ".+?", id: ".+?"\\) \\{
106106
addColumn\\(tableName: "BOOK"\\) \\{
107-
column\\(name: "PRICE", type: "INTEGER\\(10\\)"\\) \\{
107+
column\\(name: "PRICE", type: "INTEGER"\\) \\{
108108
constraints\\(nullable: "false"\\)
109109
\\}
110110
\\}

src/test/groovy/org/grails/plugins/databasemigration/command/DbmGenerateChangelogCommandSpec.groovy

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ databaseChangeLog = \\{
3838
3939
changeSet\\(author: ".*?", id: ".*?"\\) \\{
4040
createTable\\(tableName: "AUTHOR"\\) \\{
41-
column\\(autoIncrement: "true", name: "ID", type: "INT\\(10\\)"\\) \\{
41+
column\\(autoIncrement: "true", name: "ID", type: "INT"\\) \\{
4242
constraints\\(primaryKey: "true", primaryKeyName: "PK_AUTHOR"\\)
4343
\\}
4444
@@ -50,15 +50,15 @@ databaseChangeLog = \\{
5050
5151
changeSet\\(author: ".*?", id: ".*?"\\) \\{
5252
createTable\\(tableName: "BOOK"\\) \\{
53-
column\\(autoIncrement: "true", name: "ID", type: "INT\\(10\\)"\\) \\{
53+
column\\(autoIncrement: "true", name: "ID", type: "INT"\\) \\{
5454
constraints\\(primaryKey: "true", primaryKeyName: "PK_BOOK"\\)
5555
\\}
5656
5757
column\\(name: "TITLE", type: "VARCHAR\\(255\\)"\\) \\{
5858
constraints\\(nullable: "false"\\)
5959
\\}
6060
61-
column\\(name: "PRICE", type: "INT\\(10\\)"\\) \\{
61+
column\\(name: "PRICE", type: "INT"\\) \\{
6262
constraints\\(nullable: "false"\\)
6363
\\}
6464
\\}
@@ -80,7 +80,7 @@ databaseChangeLog = \\{
8080
8181
changeSet\\(author: ".*?", id: ".*?"\\) \\{
8282
createTable\\(tableName: "AUTHOR"\\) \\{
83-
column\\(autoIncrement: "true", name: "ID", type: "INT\\(10\\)"\\) \\{
83+
column\\(autoIncrement: "true", name: "ID", type: "INT"\\) \\{
8484
constraints\\(primaryKey: "true", primaryKeyName: "PK_AUTHOR"\\)
8585
\\}
8686
@@ -92,15 +92,15 @@ databaseChangeLog = \\{
9292
9393
changeSet\\(author: ".*?", id: ".*?"\\) \\{
9494
createTable\\(tableName: "BOOK"\\) \\{
95-
column\\(autoIncrement: "true", name: "ID", type: "INT\\(10\\)"\\) \\{
95+
column\\(autoIncrement: "true", name: "ID", type: "INT"\\) \\{
9696
constraints\\(primaryKey: "true", primaryKeyName: "PK_BOOK"\\)
9797
\\}
9898
9999
column\\(name: "TITLE", type: "VARCHAR\\(255\\)"\\) \\{
100100
constraints\\(nullable: "false"\\)
101101
\\}
102102
103-
column\\(name: "PRICE", type: "INT\\(10\\)"\\) \\{
103+
column\\(name: "PRICE", type: "INT"\\) \\{
104104
constraints\\(nullable: "false"\\)
105105
\\}
106106
\\}

src/test/groovy/org/grails/plugins/databasemigration/command/DbmGenerateGormChangelogCommandSpec.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ databaseChangeLog = \\{
6767
\\}
6868
6969
changeSet\\(author: ".+?", id: ".+?"\\) \\{
70-
addForeignKeyConstraint\\(baseColumnNames: "author_id", baseTableName: "book", constraintName: "FK.+?", deferrable: "false", initiallyDeferred: "false", referencedColumnNames: "id", referencedTableName: "author"\\)
70+
addForeignKeyConstraint\\(baseColumnNames: "author_id", baseTableName: "book", constraintName: "FK.+?", deferrable: "false", initiallyDeferred: "false", referencedColumnNames: "id", referencedTableName: "author", validate: "true"\\)
7171
\\}
7272
\\}
7373
'''.trim()
@@ -122,7 +122,7 @@ databaseChangeLog = \\{
122122
\\}
123123
124124
changeSet\\(author: ".+?", id: ".+?"\\) \\{
125-
addForeignKeyConstraint\\(baseColumnNames: "author_id", baseTableName: "book", constraintName: "FK.+?", deferrable: "false", initiallyDeferred: "false", referencedColumnNames: "id", referencedTableName: "author"\\)
125+
addForeignKeyConstraint\\(baseColumnNames: "author_id", baseTableName: "book", constraintName: "FK.+?", deferrable: "false", initiallyDeferred: "false", referencedColumnNames: "id", referencedTableName: "author", validate: "true"\\)
126126
\\}
127127
\\}
128128
'''.trim()

src/test/groovy/org/grails/plugins/databasemigration/command/DbmGormDiffCommandSpec.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ databaseChangeLog = \\{
5656
\\}
5757
5858
changeSet\\(author: ".+?", id: ".+?"\\) \\{
59-
addForeignKeyConstraint\\(baseColumnNames: "author_id", baseTableName: "book", constraintName: "FK.+?", deferrable: "false", initiallyDeferred: "false", referencedColumnNames: "id", referencedTableName: "author"\\)
59+
addForeignKeyConstraint\\(baseColumnNames: "author_id", baseTableName: "book", constraintName: "FK.+?", deferrable: "false", initiallyDeferred: "false", referencedColumnNames: "id", referencedTableName: "author", validate: "true"\\)
6060
\\}
6161
\\}
6262
'''.trim()
@@ -95,7 +95,7 @@ databaseChangeLog = \\{
9595
\\}
9696
9797
changeSet\\(author: ".+?", id: ".+?"\\) \\{
98-
addForeignKeyConstraint\\(baseColumnNames: "author_id", baseTableName: "book", constraintName: "FK.+?", deferrable: "false", initiallyDeferred: "false", referencedColumnNames: "id", referencedTableName: "author"\\)
98+
addForeignKeyConstraint\\(baseColumnNames: "author_id", baseTableName: "book", constraintName: "FK.+?", deferrable: "false", initiallyDeferred: "false", referencedColumnNames: "id", referencedTableName: "author", validate: "true"\\)
9999
\\}
100100
\\}
101101
'''.trim()

0 commit comments

Comments
 (0)