Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/truncate clean up method #60

Merged
merged 4 commits into from
Aug 29, 2017
Merged

feature/truncate clean up method #60

merged 4 commits into from
Aug 29, 2017

Conversation

rodionovsasha
Copy link
Owner

No description provided.


@Override
public void accept(InstructionVisitor visitor) {
visitor.visit(this);
visitor.visit(this, this.cleanMethod);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you pass this - why do you need to pass this.cleanMethod?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👎 my bad

log.info("Processing table '" + tableName + "'");
List<Instruction> fixtureInstructions = new ArrayList<>();

fixtureInstructions.addAll(table.getBeforeCleanup().stream()
.map(s -> customSql(tableName, s)).collect(Collectors.toList()));

if (CleanMethod.DELETE == table.getCleanMethod()) {
fixtureInstructions.add(cleanupTable(fixture));
if (CleanMethod.DELETE == cleanMethod || CleanMethod.TRUNCATE == cleanMethod) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (cleanMethod != CleanMethod.NONE) { ?

@@ -65,8 +67,8 @@ private void handleFixtureInstructions(Fixture fixture) {
context.getInstructions().addAll(fixtureInstructions);
}

private Instruction cleanupTable(Fixture fixture) {
return new CleanTable(fixture.name);
private Instruction cleanupTable(Fixture fixture, CleanMethod cleanMethod) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it makes sense to "inline" this method?

val table = escapeTableOrColumn(cleanTable.getTable());
val cleanMethod = cleanTable.getCleanMethod();

if (CleanMethod.DELETE == cleanMethod) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expand to switch/case with throwing IllegalStateException in default branch?

if (CleanMethod.DELETE == table.getCleanMethod()) {
fixtureInstructions.add(cleanupTable(fixture));
if (CleanMethod.DELETE == cleanMethod || CleanMethod.TRUNCATE == cleanMethod) {
fixtureInstructions.add(cleanupTable(fixture, table.getCleanMethod()));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think if we always add a CleanupTable instruction even when the CleanMethod is NONE? But in case of NONE the instruction won't add any SQL

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

@vkorobkov
Copy link
Collaborator

How does integration with slack work?

@vkorobkov
Copy link
Collaborator

Integration test 2

Copy link
Collaborator

@vkorobkov vkorobkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@rodionovsasha rodionovsasha merged commit e4f816d into master Aug 29, 2017
@rodionovsasha rodionovsasha deleted the feature/truncate branch August 29, 2017 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants