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

Improve failure message of RowCountPrecondition to preserve expected row count #3093

Merged
merged 2 commits into from Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -75,7 +75,7 @@ public void check(Database database, DatabaseChangeLog changeLog, ChangeSet chan

int result = Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", database).queryForInt(statement);
if (result != expectedRows) {
throw new PreconditionFailedException(getFailureMessage(result), changeLog, this);
throw new PreconditionFailedException(getFailureMessage(result, expectedRows), changeLog, this);
}

} catch (PreconditionFailedException e) {
Expand All @@ -85,8 +85,8 @@ public void check(Database database, DatabaseChangeLog changeLog, ChangeSet chan
}
}

protected String getFailureMessage(int result) {
return "Table "+tableName+" is not empty. Contains "+result+" rows";
protected String getFailureMessage(int result, int expectedRows) {
return "Table "+tableName+" does not have the expected row count of "+expectedRows+". It contains "+result+" rows";
}

@Override
Expand Down
Expand Up @@ -7,7 +7,7 @@ public TableIsEmptyPrecondition() {
}

@Override
protected String getFailureMessage(int result) {
protected String getFailureMessage(int result, int expectedRows) {
return "Table "+getTableName()+" is not empty. Contains "+result+" rows";
}

Expand Down