defaults:
bmo_slim_image: &bmo_slim_image
- image: mozillabteam/bmo-slim:20190322.1
+ image: mozillabteam/bmo-slim:20190404.1
user: app
mysql_image: &mysql_image
package Bugzilla::Model::Result::Bug;
use Mojo::Base 'DBIx::Class::Core';
-__PACKAGE__->load_components('Helper::Row::NumifyGet');
+__PACKAGE__->load_components(qw( Helper::Row::NumifyGet InflateColumn::DateTime ));
__PACKAGE__->table(Bugzilla::Bug->DB_TABLE);
__PACKAGE__->add_columns(Bugzilla::Bug->DB_COLUMN_NAMES);
__PACKAGE__->add_columns(
- '+bug_id' => {is_numeric => 1},
- '+reporter' => {is_numeric => 1},
- '+qa_contact' => {is_numeric => 1},
+ '+bug_id' => {is_numeric => 1},
+ '+reporter' => {is_numeric => 1},
+ '+qa_contact' => {is_numeric => 1},
'+assigned_to' => {is_numeric => 1},
+ '+delta_ts' => {data_type => 'timestamp'},
);
__PACKAGE__->set_primary_key(Bugzilla::Bug->ID_FIELD);
flags => [map { $self->_prepare_flag($_) } $bug->flags->all],
};
- return ($bug->id, $doc);
+ return ($self->_prepare_doc_id($bug), $doc);
+}
+
+sub _prepare_doc_id {
+ my ($self, $bug) = @_;
+
+ return sprintf("%d-%d", $bug->id, $bug->delta_ts->epoch);
}
sub _prepare_flag {
-FROM mozillabteam/bmo-slim:20190322.1
+FROM mozillabteam/bmo-slim:20190404.1
ARG CI
ARG CIRCLE_SHA1
);
my %build_requires = ('ExtUtils::MakeMaker' => '7.22',);
-my %test_requires = (
- 'Capture::Tiny' => 0,
- 'DBD::SQLite' => '1.29',
- 'Perl::Critic::Freenode' => 0,
- 'Perl::Tidy' => '20180220',
- 'Pod::Coverage' => 0,
- 'Test::More' => 0,
- 'Test::Perl::Critic::Progressive' => 0,
- 'Test::Selenium::Firefox' => 0,
- 'Selenium::Remote::Driver' => 1.31,
- 'Test::WWW::Selenium' => 0,
- 'Test2::V0' => 0,
-);
my %recommends = (Safe => '2.30',);
# Windows requires some additional modules.
},
sqlite => {
description => 'SQLite database support',
- prereqs => {runtime => {requires => {'DBD::SQLite' => '1.29'}}},
+ prereqs => {runtime => {requires => {'DBD::SQLite' => '1.29', 'DateTime::Format::SQLite' => '0.11'}}},
},
mysql => {
description => 'MySQL database support',
- prereqs => {runtime => {requires => {'DBD::mysql' => '4.037'}}}
+ prereqs => {runtime => {requires => {'DBD::mysql' => '4.037', 'DateTime::Format::MySQL' => '0.06'}}}
},
jsonrpc => {
description => 'JSON-RPC Interface',
}
}
+my %test_requires = (
+ %{ $optional_features{sqlite}{prereqs}{runtime}{requires} },
+ 'Capture::Tiny' => 0,
+ 'DBD::SQLite' => '1.29',
+ 'Perl::Critic::Freenode' => 0,
+ 'Perl::Tidy' => '20180220',
+ 'Pod::Coverage' => 0,
+ 'Test::More' => 0,
+ 'Test::Perl::Critic::Progressive' => 0,
+ 'Test::Selenium::Firefox' => 0,
+ 'Selenium::Remote::Driver' => 1.31,
+ 'Test::WWW::Selenium' => 0,
+ 'Test2::V0' => 0,
+);
+
# BMO Customization
my @bmo_features = grep { is_bmo_feature($_) } keys %optional_features;
BEGIN {
unlink('data/db/report_ping_simple') if -f 'data/db/report_ping_simple';
$ENV{test_db_name} = 'report_ping_simple';
+ # Our code will store dates in localtime with sqlite.
+ # So for these tests to pass, everything should be UTC.
+ $ENV{TZ} = 'UTC';
}
use Bugzilla::Test::MockDB;
use Bugzilla::Test::MockParams (password_complexity => 'no_constraints');
use Bugzilla::Test::Util qw(create_bug create_user);
use Bugzilla;
+use Bugzilla::Util qw(datetime_from);
use Bugzilla::Constants;
use Bugzilla::Hook;
BEGIN { Bugzilla->extensions }
Bugzilla->dbh->model->resultset('Keyword')
->create({name => 'regression', description => 'the regression keyword'});
+# Our code will store dates in localtime with sqlite.
+# So for these tests to pass, everything should be UTC.
+my $UTC = DateTime::TimeZone->new(name => 'UTC');
+Bugzilla->local_timezone($UTC);
+my $User = mock 'Bugzilla::User' => (
+ override => [ timezone => sub { $UTC } ]
+);
+
my $user = create_user('reportuser@invalid.tld', '*');
Bugzilla->set_user($user);
-create_bug(
- short_desc => "test bug $_",
- comment => "Hello, world: $_",
- provided $_ % 3 == 0, keywords => ['regression'],
- assigned_to => 'reportuser@invalid.tld'
-) for (1..250);
+
+my %time;
+for (1..250) {
+ my $bug = create_bug(
+ short_desc => "test bug $_",
+ comment => "Hello, world: $_",
+ provided $_ % 3 == 0, keywords => ['regression'],
+ assigned_to => 'reportuser@invalid.tld'
+ );
+ $time{ $bug->id } = datetime_from($bug->delta_ts)->epoch;
+}
my $report = Bugzilla::Report::Ping::Simple->new(
base_url => 'http://localhost',
my ($first, $second, $third, @rest) = $rs->all;
{
my ($id, $doc) = $report->prepare( $first );
- is($id, 1, "doc id is 1");
+
+ is($id, "1-$time{1}", "doc id is correct");
is($doc->{product}, 'Firefox');
is($doc->{keywords}, []);
is([map { "$_" } $report->validate($doc)], [], "No errors for first doc");
{
my ($id, $doc) = $report->prepare( $third );
- is($id, 3, "doc id is 3");
+ is($id, "3-$time{3}", "doc id is correct");
is($doc->{product}, 'Firefox');
is($doc->{keywords}, ['regression']);
}