From ea5beeacb185309572836cc60989f95ea4705f9d Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Fri, 10 Aug 2018 15:41:53 -0400 Subject: Bug 1482475 - Add extensive testing framework --- t/sqlite-memory.t | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 t/sqlite-memory.t (limited to 't/sqlite-memory.t') diff --git a/t/sqlite-memory.t b/t/sqlite-memory.t new file mode 100644 index 000000000..66f8e5d29 --- /dev/null +++ b/t/sqlite-memory.t @@ -0,0 +1,89 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. +use 5.10.1; +use strict; +use warnings; +use lib qw( . lib local/lib/perl5 ); +use Test::More; +use Test2::Tools::Mock; +use Try::Tiny; +use Capture::Tiny qw(capture_merged); +use Bugzilla::Test::MockParams; + +BEGIN { + $ENV{LOCALCONFIG_ENV} = 'BMO'; + $ENV{BMO_db_driver} = 'sqlite'; + $ENV{BMO_db_name} = ':memory:'; +}; +use Bugzilla; +BEGIN { Bugzilla->extensions }; + + +isa_ok(Bugzilla->dbh, 'Bugzilla::DB::Sqlite'); + +use ok 'Bugzilla::Install'; +use ok 'Bugzilla::Install::DB'; + +my $lives_ok = sub { + my ($desc, $code) = @_; + my $output; + try { + $output = capture_merged { $code->() }; + pass($desc); + } catch { + diag $_; + fail($desc); + } finally { + diag "OUTPUT: $output" if $output; + }; +}; + +my $output = ''; +$lives_ok->('bz_setup_database' => sub { + Bugzilla->dbh->bz_setup_database +}); + +$lives_ok->('bz_populate_enum_tables' => sub { + # Populate the tables that hold the values for the