Skip to content

Commit

Permalink
Merge pull request #3093 from martinspielmann/master
Browse files Browse the repository at this point in the history
Improve failure message of RowCountPrecondition to preserve expected row count
  • Loading branch information
nvoxland committed Aug 1, 2022
2 parents c91baf2 + 0a4c5f6 commit 9c4e585
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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

0 comments on commit 9c4e585

Please sign in to comment.