Skip to content

Commit

Permalink
Issue 21: Apply flyway info on plan
Browse files Browse the repository at this point in the history
  • Loading branch information
kmanning committed Apr 9, 2021
1 parent b0bc245 commit 020f0cd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/FlywayMigrationPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ class FlywayMigrationPlugin implements TerraformEnvironmentStagePlugin {
}

public void apply(TerraformEnvironmentStage stage) {
println "do the thing"
stage.decorate(TerraformEnvironmentStage.PLAN, flywayInfoClosure())
}

public Closure flywayInfoClosure() {
return { innerClosure ->
innerClosure()
sh "echo run flyway info"
}
}
}
19 changes: 19 additions & 0 deletions test/FlywayMigrationPluginTest.groovy
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import static org.hamcrest.Matchers.hasItem
import static org.hamcrest.Matchers.instanceOf
import static org.hamcrest.MatcherAssert.assertThat
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;

import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
Expand All @@ -18,5 +22,20 @@ class FlywayMigrationPluginTest {
assertThat(actualPlugins, hasItem(instanceOf(FlywayMigrationPlugin.class)))
}
}

@Nested
public class Apply {
@Test
void addsFlywayInfoClosureOnPlan() {
def infoClosure = { -> }
def plugin = spy(new FlywayMigrationPlugin())
doReturn(infoClosure).when(plugin).flywayInfoClosure()
def stage = mock(TerraformEnvironmentStage.class)

plugin.apply(stage)

verify(stage).decorate(TerraformEnvironmentStage.PLAN, infoClosure)
}
}
}

0 comments on commit 020f0cd

Please sign in to comment.