Skip to content

Commit a9891c6

Browse files
committed
WIP: start sketching out flway migrate on apply
1 parent 43f3365 commit a9891c6

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/FlywayMigrationPlugin.groovy

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class FlywayMigrationPlugin implements TerraformEnvironmentStagePlugin, Resettab
88

99
public void apply(TerraformEnvironmentStage stage) {
1010
stage.decorate(TerraformEnvironmentStage.PLAN, flywayInfoClosure())
11+
stage.decorate(TerraformEnvironmentStage.APPLY, flywayMigrateClosure())
1112
}
1213

1314
public Closure flywayInfoClosure() {
@@ -22,6 +23,14 @@ class FlywayMigrationPlugin implements TerraformEnvironmentStagePlugin, Resettab
2223
}
2324
}
2425

26+
public Closure flywayMigrateClosure() {
27+
return { innerClosure ->
28+
innerClosure()
29+
30+
sh "echo run flyway migrate"
31+
}
32+
}
33+
2534
public Collection buildEnvironmentVariableList(env) {
2635
def list = []
2736
if (passwordVariable) {

test/FlywayMigrationPluginTest.groovy

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ class FlywayMigrationPluginTest {
3939

4040
verify(stage).decorate(TerraformEnvironmentStage.PLAN, infoClosure)
4141
}
42+
43+
@Test
44+
void addsFlywayMigrateClosureOnApply() {
45+
def migrateClosure = { -> }
46+
def plugin = spy(new FlywayMigrationPlugin())
47+
doReturn(migrateClosure).when(plugin).flywayMigrateClosure()
48+
def stage = mock(TerraformEnvironmentStage.class)
49+
50+
plugin.apply(stage)
51+
52+
verify(stage).decorate(TerraformEnvironmentStage.APPLY, migrateClosure)
53+
}
4254
}
4355

4456
@Nested

0 commit comments

Comments
 (0)