Use better message for consistency check (#19672)
- Don't log the reflect struct, but instead log the ID of the struct. This improves the error message, as you would actually know which row is the error.
This commit is contained in:
parent
64a40962cc
commit
9d0253a9fa
1 changed files with 15 additions and 15 deletions
|
@ -73,8 +73,8 @@ func init() {
|
|||
AssertCountByCond(t, "follow", builder.Eq{"user_id": user.int("ID")}, user.int("NumFollowing"))
|
||||
AssertCountByCond(t, "follow", builder.Eq{"follow_id": user.int("ID")}, user.int("NumFollowers"))
|
||||
if user.int("Type") != modelsUserTypeOrganization {
|
||||
assert.EqualValues(t, 0, user.int("NumMembers"))
|
||||
assert.EqualValues(t, 0, user.int("NumTeams"))
|
||||
assert.EqualValues(t, 0, user.int("NumMembers"), "Unexpected number of members for user id: %d", user.int("ID"))
|
||||
assert.EqualValues(t, 0, user.int("NumTeams"), "Unexpected number of teams for user id: %d", user.int("ID"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,37 +91,37 @@ func init() {
|
|||
actual := GetCountByCond(t, "watch", builder.Eq{"repo_id": repo.int("ID")}.
|
||||
And(builder.Neq{"mode": modelsRepoWatchModeDont}))
|
||||
assert.EqualValues(t, repo.int("NumWatches"), actual,
|
||||
"Unexpected number of watches for repo %+v", repo)
|
||||
"Unexpected number of watches for repo id: %d", repo.int("ID"))
|
||||
|
||||
actual = GetCountByCond(t, "issue", builder.Eq{"is_pull": false, "repo_id": repo.int("ID")})
|
||||
assert.EqualValues(t, repo.int("NumIssues"), actual,
|
||||
"Unexpected number of issues for repo %+v", repo)
|
||||
"Unexpected number of issues for repo id: %d", repo.int("ID"))
|
||||
|
||||
actual = GetCountByCond(t, "issue", builder.Eq{"is_pull": false, "is_closed": true, "repo_id": repo.int("ID")})
|
||||
assert.EqualValues(t, repo.int("NumClosedIssues"), actual,
|
||||
"Unexpected number of closed issues for repo %+v", repo)
|
||||
"Unexpected number of closed issues for repo id: %d", repo.int("ID"))
|
||||
|
||||
actual = GetCountByCond(t, "issue", builder.Eq{"is_pull": true, "repo_id": repo.int("ID")})
|
||||
assert.EqualValues(t, repo.int("NumPulls"), actual,
|
||||
"Unexpected number of pulls for repo %+v", repo)
|
||||
"Unexpected number of pulls for repo id: %d", repo.int("ID"))
|
||||
|
||||
actual = GetCountByCond(t, "issue", builder.Eq{"is_pull": true, "is_closed": true, "repo_id": repo.int("ID")})
|
||||
assert.EqualValues(t, repo.int("NumClosedPulls"), actual,
|
||||
"Unexpected number of closed pulls for repo %+v", repo)
|
||||
"Unexpected number of closed pulls for repo id: %d", repo.int("ID"))
|
||||
|
||||
actual = GetCountByCond(t, "milestone", builder.Eq{"is_closed": true, "repo_id": repo.int("ID")})
|
||||
assert.EqualValues(t, repo.int("NumClosedMilestones"), actual,
|
||||
"Unexpected number of closed milestones for repo %+v", repo)
|
||||
"Unexpected number of closed milestones for repo id: %d", repo.int("ID"))
|
||||
}
|
||||
|
||||
checkForIssueConsistency := func(t assert.TestingT, bean interface{}) {
|
||||
issue := reflectionWrap(bean)
|
||||
typeComment := modelsCommentTypeComment
|
||||
actual := GetCountByCond(t, "comment", builder.Eq{"`type`": typeComment, "issue_id": issue.int("ID")})
|
||||
assert.EqualValues(t, issue.int("NumComments"), actual, "Unexpected number of comments for issue %+v", issue)
|
||||
assert.EqualValues(t, issue.int("NumComments"), actual, "Unexpected number of comments for issue id: %d", issue.int("ID"))
|
||||
if issue.bool("IsPull") {
|
||||
prRow := AssertExistsAndLoadMap(t, "pull_request", builder.Eq{"issue_id": issue.int("ID")})
|
||||
assert.EqualValues(t, parseInt(prRow["index"]), issue.int("Index"))
|
||||
assert.EqualValues(t, parseInt(prRow["index"]), issue.int("Index"), "Unexpected index for issue id: %d", issue.int("ID"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ func init() {
|
|||
pr := reflectionWrap(bean)
|
||||
issueRow := AssertExistsAndLoadMap(t, "issue", builder.Eq{"id": pr.int("IssueID")})
|
||||
assert.True(t, parseBool(issueRow["is_pull"]))
|
||||
assert.EqualValues(t, parseInt(issueRow["index"]), pr.int("Index"))
|
||||
assert.EqualValues(t, parseInt(issueRow["index"]), pr.int("Index"), "Unexpected index for pull request id: %d", pr.int("ID"))
|
||||
}
|
||||
|
||||
checkForMilestoneConsistency := func(t assert.TestingT, bean interface{}) {
|
||||
|
@ -137,7 +137,7 @@ func init() {
|
|||
AssertCountByCond(t, "issue", builder.Eq{"milestone_id": milestone.int("ID")}, milestone.int("NumIssues"))
|
||||
|
||||
actual := GetCountByCond(t, "issue", builder.Eq{"is_closed": true, "milestone_id": milestone.int("ID")})
|
||||
assert.EqualValues(t, milestone.int("NumClosedIssues"), actual, "Unexpected number of closed issues for milestone %+v", milestone)
|
||||
assert.EqualValues(t, milestone.int("NumClosedIssues"), actual, "Unexpected number of closed issues for milestone id: %d", milestone.int("ID"))
|
||||
|
||||
completeness := 0
|
||||
if milestone.int("NumIssues") > 0 {
|
||||
|
@ -153,7 +153,7 @@ func init() {
|
|||
Query()
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.EqualValues(t, label.int("NumIssues"), len(issueLabels), "Unexpected number of issue for label %+v", label)
|
||||
assert.EqualValues(t, label.int("NumIssues"), len(issueLabels), "Unexpected number of issue for label id: %d", label.int("ID"))
|
||||
|
||||
issueIDs := make([]int, len(issueLabels))
|
||||
for i, issueLabel := range issueLabels {
|
||||
|
@ -164,7 +164,7 @@ func init() {
|
|||
if len(issueIDs) > 0 {
|
||||
expected = GetCountByCond(t, "issue", builder.In("id", issueIDs).And(builder.Eq{"is_closed": true}))
|
||||
}
|
||||
assert.EqualValues(t, expected, label.int("NumClosedIssues"), "Unexpected number of closed issues for label %+v", label)
|
||||
assert.EqualValues(t, expected, label.int("NumClosedIssues"), "Unexpected number of closed issues for label id: %d", label.int("ID"))
|
||||
}
|
||||
|
||||
checkForTeamConsistency := func(t assert.TestingT, bean interface{}) {
|
||||
|
@ -177,7 +177,7 @@ func init() {
|
|||
action := reflectionWrap(bean)
|
||||
if action.int("RepoID") != 1700 { // dangling intentional
|
||||
repoRow := AssertExistsAndLoadMap(t, "repository", builder.Eq{"id": action.int("RepoID")})
|
||||
assert.Equal(t, parseBool(repoRow["is_private"]), action.bool("IsPrivate"), "action: %+v", action)
|
||||
assert.Equal(t, parseBool(repoRow["is_private"]), action.bool("IsPrivate"), "Unexpected is_private field for action id: %d", action.int("ID"))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue