Make LabelTypeIT tests assume copy-score defaults now initialized herein

Remove overriding settings from LabelTypeIT setUp so that those tests
assume defaults defined in LabelType (and exercised in ProjectConfig).

Add initialization of such defaults to LabelType constructor; otherwise,
defaults set to true were not initialized as such, served false instead.

Add mentions of false defaults to Documentation, for copyMinScore and
copyMaxScore (used to be missing). Only allProjects had its copyMinScore
default set to true, in AllProjectsCreator (initCodeReviewLabel).

Change-Id: I7957ff8d628d7e1744a910e66dcae6b41343a7e7
This commit is contained in:
Marco Miller
2015-03-13 17:20:44 -04:00
committed by David Pursehouse
parent 5a65d032f3
commit 5f834717cc
3 changed files with 16 additions and 10 deletions

View File

@@ -222,7 +222,8 @@ determining whether a change is submittable.
=== `label.Label-Name.copyMinScore`
If true, the lowest possible negative value for the label is copied
forward when a new patch set is uploaded.
forward when a new patch set is uploaded. Defaults to false, except
for All-Projects which has it true by default.
[[label_copyMaxScore]]
=== `label.Label-Name.copyMaxScore`
@@ -230,7 +231,7 @@ forward when a new patch set is uploaded.
If true, the highest possible positive value for the label is copied
forward when a new patch set is uploaded. This can be used to enable
sticky approvals, reducing turn-around for trivial cleanups prior to
submitting a change.
submitting a change. Defaults to false.
[[label_copyAllScoresOnTrivialRebase]]
=== `label.Label-Name.copyAllScoresOnTrivialRebase`

View File

@@ -48,17 +48,16 @@ public class LabelTypeIT extends AbstractDaemonTest {
public void setUp() throws Exception {
ProjectConfig cfg = projectCache.checkedGet(allProjects).getConfig();
codeReview = checkNotNull(cfg.getLabelSections().get("Code-Review"));
codeReview.setCopyMinScore(false);
codeReview.setCopyMaxScore(false);
codeReview.setCopyAllScoresOnTrivialRebase(false);
codeReview.setCopyAllScoresIfNoCodeChange(false);
codeReview.setCopyAllScoresIfNoChange(false);
codeReview.setDefaultValue((short)-1);
saveProjectConfig(cfg);
}
@Test
public void noCopyMinScoreOnRework() throws Exception {
//allProjects only has it true by default
codeReview.setCopyMinScore(false);
saveLabelConfig();
PushOneCommit.Result r = createChange();
revision(r).review(ReviewInput.reject());
assertApproval(r, -2);
@@ -72,7 +71,7 @@ public class LabelTypeIT extends AbstractDaemonTest {
saveLabelConfig();
PushOneCommit.Result r = createChange();
revision(r).review(ReviewInput.reject());
//assertApproval(r, -2);
assertApproval(r, -2);
r = amendChange(r.getChangeId());
assertApproval(r, -2);
}
@@ -125,6 +124,8 @@ public class LabelTypeIT extends AbstractDaemonTest {
@Test
public void noCopyAllScoresIfNoChange() throws Exception {
codeReview.setCopyAllScoresIfNoChange(false);
saveLabelConfig();
PushOneCommit.Result patchSet = readyPatchSetForNoChangeRebase();
rebase(patchSet);
assertApproval(patchSet, 0);
@@ -133,8 +134,6 @@ public class LabelTypeIT extends AbstractDaemonTest {
@Test
public void copyAllScoresIfNoChange() throws Exception {
PushOneCommit.Result patchSet = readyPatchSetForNoChangeRebase();
codeReview.setCopyAllScoresIfNoChange(true);
saveLabelConfig();
rebase(patchSet);
assertApproval(patchSet, 1);
}

View File

@@ -134,6 +134,12 @@ public class LabelType {
maxPositive = values.get(values.size() - 1).getValue();
}
}
setCanOverride(DEF_CAN_OVERRIDE);
setCopyAllScoresIfNoChange(DEF_COPY_ALL_SCORES_IF_NO_CHANGE);
setCopyAllScoresIfNoCodeChange(DEF_COPY_ALL_SCORES_IF_NO_CODE_CHANGE);
setCopyAllScoresOnTrivialRebase(DEF_COPY_ALL_SCORES_ON_TRIVIAL_REBASE);
setCopyMaxScore(DEF_COPY_MAX_SCORE);
setCopyMinScore(DEF_COPY_MIN_SCORE);
}
public String getName() {