aboutsummaryrefslogtreecommitdiff
path: root/xt
diff options
context:
space:
mode:
Diffstat (limited to 'xt')
-rw-r--r--xt/lib/Bugzilla/Test/Search.pm10
-rw-r--r--xt/lib/Bugzilla/Test/Search/Constants.pm29
-rw-r--r--xt/lib/Bugzilla/Test/Search/FieldTest.pm18
3 files changed, 41 insertions, 16 deletions
diff --git a/xt/lib/Bugzilla/Test/Search.pm b/xt/lib/Bugzilla/Test/Search.pm
index 624db8e2c..0c14de823 100644
--- a/xt/lib/Bugzilla/Test/Search.pm
+++ b/xt/lib/Bugzilla/Test/Search.pm
@@ -304,7 +304,7 @@ sub create_keyword {
sub create_user {
my ($prefix) = @_;
- my $user_name = $prefix . '-' . random(10) . "@" . random(10)
+ my $user_name = $prefix . '-' . random(15) . "@" . random(12)
. "." . random(3);
my $user_realname = $prefix . '-' . random();
my $user = Bugzilla::User->create({
@@ -376,7 +376,7 @@ sub _create_field_values {
$values{'keywords'} = create_keyword($number)->name;
foreach my $field qw(assigned_to qa_contact reporter cc) {
- $values{$field} = create_user("$number-$field-")->login;
+ $values{$field} = create_user("$number-$field")->login;
}
my $classification = Bugzilla::Classification->create(
@@ -417,7 +417,7 @@ sub _create_field_values {
# "short_desc" as a word and matches it in every bug.
my $value = "$number-$field" . random();
if ($field eq 'bug_file_loc' or $field eq 'see_also') {
- $value = "http://$value" . random(3)
+ $value = "http://$value-" . random(3)
. "/show_bug.cgi?id=$number";
}
$values{$field} = $value;
@@ -441,8 +441,8 @@ sub _create_field_values {
. ' ' . random();
my @flags;
- my $setter = create_user("$number-setter");
- my $requestee = create_user("$number-requestee");
+ my $setter = create_user("$number-setters.login_name");
+ my $requestee = create_user("$number-requestees.login_name");
$values{set_flags} = _create_flags($number, $setter, $requestee);
my $month = $for_create ? "12" : "02";
diff --git a/xt/lib/Bugzilla/Test/Search/Constants.pm b/xt/lib/Bugzilla/Test/Search/Constants.pm
index 248b59f53..2b3534f8b 100644
--- a/xt/lib/Bugzilla/Test/Search/Constants.pm
+++ b/xt/lib/Bugzilla/Test/Search/Constants.pm
@@ -48,6 +48,7 @@ our @EXPORT = qw(
OR_SKIP
PG_BROKEN
SKIP_FIELDS
+ SUBSTR_NO_FIELD_ADD
SUBSTR_SIZE
TESTS
TESTS_PER_RUN
@@ -158,22 +159,35 @@ use constant USER_FIELDS => qw(
);
# For the "substr"-type searches, how short of a substring should
-# we use?
+# we use? The goal is to be shorter than the full string, but
+# long enough to still be globally unique.
use constant SUBSTR_SIZE => 20;
# However, for some fields, we use a different size.
use constant FIELD_SUBSTR_SIZE => {
- alias => 12,
- bug_file_loc => 30,
+ alias => 11,
# Just the month and day.
deadline => -5,
creation_ts => -8,
delta_ts => -8,
+ percentage_complete => 7,
work_time => 3,
remaining_time => 3,
- see_also => 30,
- target_milestone => 12,
+ target_milestone => 15,
+ longdesc => 25,
+ # Just the hour and minute.
+ FIELD_TYPE_DATETIME, -5,
};
+# For most fields, we add the length of the name of the field plus
+# the SUBSTR_SIZE specified above to determine how large of a substring
+# we're going to use. However, for some fields, it doesn't make sense to
+# add in their field name this way.
+use constant SUBSTR_NO_FIELD_ADD => FIELD_TYPE_DATETIME, qw(
+ target_milestone remaining_time percentage_complete work_time
+ attachments.mimetype attachments.submitter attachments.filename
+ attachments.description flagtypes.name
+);
+
################
# Known Broken #
################
@@ -364,9 +378,6 @@ use constant KNOWN_BROKEN => {
anyexact => {
percentage_complete => { contains => [2] },
},
- anywordssubstr => {
- percentage_complete => { contains => [2] },
- },
'allwordssubstr-<1>' => { ALLWORDS_BROKEN },
# flagtypes.name does not work here, probably because they all try to
@@ -623,7 +634,7 @@ use constant BROKEN_NOT => {
"work_time" => { contains => [1, 2] },
},
'anywordssubstr-<1> <2>' => {
- percentage_complete => { contains => [1,3,4,5] },
+ percentage_complete => { contains => [1,2,3,4,5] },
FIELD_TYPE_MULTI_SELECT, { contains => [5] },
},
casesubstring => {
diff --git a/xt/lib/Bugzilla/Test/Search/FieldTest.pm b/xt/lib/Bugzilla/Test/Search/FieldTest.pm
index f8186c5b3..b5f6d2334 100644
--- a/xt/lib/Bugzilla/Test/Search/FieldTest.pm
+++ b/xt/lib/Bugzilla/Test/Search/FieldTest.pm
@@ -461,13 +461,27 @@ sub _translate_value_for_bug {
sub _substr_value {
my ($self, $value) = @_;
my $field = $self->field;
+ my $type = $self->field_object->type;
my $substr_size = SUBSTR_SIZE;
if (exists FIELD_SUBSTR_SIZE->{$field}) {
$substr_size = FIELD_SUBSTR_SIZE->{$field};
}
-
+ elsif (exists FIELD_SUBSTR_SIZE->{$type}) {
+ $substr_size = FIELD_SUBSTR_SIZE->{$type};
+ }
if ($substr_size > 0) {
- return substr($value, 0, $substr_size);
+ # The field name is included in every field value, and if it's
+ # long, it might take up the whole substring, and we don't want that.
+ if (!grep { $_ eq $field or $_ eq $type } SUBSTR_NO_FIELD_ADD) {
+ $substr_size += length($field);
+ }
+ my $string = substr($value, 0, $substr_size);
+ # Make percentage_complete substrings strings match integers uniquely,
+ # by searching for the full decimal number.
+ if ($field eq 'percentage_complete' and length($string) < $substr_size) {
+ $string .= ".000";
+ }
+ return $string;
}
return substr($value, $substr_size);
}