-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing test issues
- Loading branch information
Showing
13 changed files
with
114 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
backend/src/test/groovy/edu/internet2/tier/shibboleth/admin/ui/ResetDatabase.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui | ||
|
||
import groovy.sql.Sql | ||
|
||
trait ResetsDatabase { | ||
static final String H2_BACKUP_LOCATION = '/tmp/h2backup.sql' | ||
|
||
void dbsetup() { | ||
if (new File(H2_BACKUP_LOCATION).exists()) { | ||
print "Previous test was interrupted and did not clean up after itself. " | ||
loadH2FromBackup() | ||
} | ||
else { | ||
Sql sql = connectToSql() | ||
sql.execute("SCRIPT TO ?", [H2_BACKUP_LOCATION]) | ||
} | ||
} | ||
|
||
void dbcleanup() { | ||
loadH2FromBackup() | ||
new File(H2_BACKUP_LOCATION).delete() | ||
} | ||
|
||
private void loadH2FromBackup() { | ||
println "Restoring H2 from backup location." | ||
Sql sql = connectToSql() | ||
sql.execute("DROP ALL OBJECTS") | ||
sql.execute("RUNSCRIPT FROM ?", [H2_BACKUP_LOCATION]) | ||
} | ||
|
||
private Sql connectToSql() { | ||
Sql.newInstance('jdbc:h2:file:/tmp/myApplicationDb;AUTO_SERVER=TRUE', 'sa', '', 'org.h2.Driver') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.