summaryrefslogtreecommitdiff
path: root/t/engine.t
diff options
context:
space:
mode:
Diffstat (limited to 't/engine.t')
-rwxr-xr-xt/engine.t53
1 files changed, 38 insertions, 15 deletions
diff --git a/t/engine.t b/t/engine.t
index ee971371..f7bfa8e8 100755
--- a/t/engine.t
+++ b/t/engine.t
@@ -4,7 +4,7 @@ use strict;
use warnings;
use 5.010;
use utf8;
-use Test::More tests => 775;
+use Test::More tests => 781;
# use Test::More 'no_plan';
use App::Sqitch;
use App::Sqitch::Plan;
@@ -14,7 +14,7 @@ use Test::Exception;
use Test::NoWarnings;
use Test::MockModule;
use Test::MockObject::Extends;
-use Test::Warn qw(warning_is);
+use Test::Warn 0.31 qw(warning_is);
use Time::HiRes qw(sleep);
use Locale::TextDomain qw(App-Sqitch);
use App::Sqitch::X qw(hurl);
@@ -1169,6 +1169,7 @@ is_deeply +MockOutput->get_info, [
], 'Should have emitted deploy announcement and successes';
# Make sure we can deploy everything by change.
+MockOutput->clear;
$latest_change_id = undef;
$plan->reset;
$plan->add( name => 'lolz', note => 'ha ha' );
@@ -1208,6 +1209,15 @@ is_deeply +MockOutput->get_info_literal, [
[' + lolz ..', '.........', ' '],
], 'Should have seen the output of the deploy to the end';
+is_deeply +MockOutput->get_debug, [
+ [__ 'Will deploy the following changes:' ],
+ ['roles'],
+ ['users @alpha'],
+ ['widgets @beta'],
+ ['lolz'],
+], 'Debug output should show what will be deployed';
+
+
# If we deploy again, it should be up-to-date.
$latest_change_id = $changes[-1]->id;
ok $engine->deploy, 'Should return success for deploy to up-to-date DB';
@@ -1928,6 +1938,8 @@ is_deeply $engine->seen, [
is_deeply +MockOutput->get_info, [], 'Nothing should have been output';
# Make sure deprecation warning happens.
+# Test only the first line of the warning. Reason:
+# https://github.com/hanfried/test-warn/issues/9
warning_is { $engine->revert }
"Engine::revert() requires the `prompt` and `prompt_default` arguments.\n",
'Should get warning omitting required arguments';
@@ -2050,6 +2062,7 @@ my @dbchanges;
$params;
} @changes[0..3];
+MockOutput->clear;
MockOutput->ask_yes_no_returns(1);
is $engine->revert(undef, 1, 1), $engine, 'Revert all changes';
is_deeply $engine->seen, [
@@ -2077,12 +2090,14 @@ is_deeply +MockOutput->get_info_literal, [
[' - users @alpha ..', '.', ' '],
[' - roles ..', '........', ' '],
], 'It should have said it was reverting all changes and listed them';
-is_deeply +MockOutput->get_info, [
+is_deeply +MockOutput->get_debug, [
[__ 'Would revert the following changes:'],
['roles'],
['users @alpha'],
['widgets @beta'],
['lolz'],
+], 'Output should show what would be reverted';
+is_deeply +MockOutput->get_info, [
[__ 'ok'],
[__ 'ok'],
[__ 'ok'],
@@ -2114,12 +2129,14 @@ is_deeply +MockOutput->get_info_literal, [
[' - users @alpha ..', '.', ' '],
[' - roles ..', '........', ' '],
], 'It should have said it was reverting all changes and listed them';
-is_deeply +MockOutput->get_info, [
+is_deeply +MockOutput->get_debug, [
[__ 'Would revert the following changes:'],
['roles'],
['users @alpha'],
['widgets @beta'],
['lolz'],
+], 'Output should show what would be reverted';
+is_deeply +MockOutput->get_info, [
[__ 'ok'],
[__ 'ok'],
[__ 'ok'],
@@ -2142,13 +2159,13 @@ is_deeply +MockOutput->get_ask_yes_no, [
destination => $engine->destination,
), 1],
], 'Should have prompt to revert all changes';
-is_deeply +MockOutput->get_info, [
+is_deeply +MockOutput->get_debug, [
[__ 'Would revert the following changes:'],
['roles'],
['users @alpha'],
['widgets @beta'],
['lolz'],
-], 'It should have emitted nothing else';
+], 'Output should show what would be reverted';
# Revert all changes with no prompt.
MockOutput->ask_yes_no_returns(1);
@@ -2180,16 +2197,18 @@ is_deeply +MockOutput->get_info, [
'Reverting all changes from {destination}',
destination => $engine->destination,
)],
- [__ 'Will revert the following changes:'],
- ['roles'],
- ['users @alpha'],
- ['widgets @beta'],
- ['lolz'],
[__ 'ok'],
[__ 'ok'],
[__ 'ok'],
[__ 'ok'],
], 'And the revert successes should be emitted';
+is_deeply +MockOutput->get_debug, [
+ [__ 'Will revert the following changes:'],
+ ['roles'],
+ ['users @alpha'],
+ ['widgets @beta'],
+ ['lolz'],
+], 'Output should show what will be reverted';
# Now just revert to an earlier change.
$offset_change = $dbchanges[1];
@@ -2220,10 +2239,12 @@ is_deeply +MockOutput->get_info_literal, [
[' - lolz ..', '.........', ' '],
[' - widgets @beta ..', '', ' '],
], 'Output should show what it reverts to';
-is_deeply +MockOutput->get_info, [
+is_deeply +MockOutput->get_debug, [
[__ 'Would revert the following changes:'],
['widgets @beta'],
['lolz'],
+], 'Output should show what would be reverted';
+is_deeply +MockOutput->get_info, [
[__ 'ok'],
[__ 'ok'],
], 'And the revert successes should be emitted';
@@ -2249,7 +2270,7 @@ is_deeply +MockOutput->get_ask_yes_no, [
destination => $engine->destination,
), 1],
], 'Should have prompt to revert to @alpha';
-is_deeply +MockOutput->get_info, [
+is_deeply +MockOutput->get_debug, [
[__ 'Would revert the following changes:'],
['widgets @beta'],
['lolz'],
@@ -2282,10 +2303,12 @@ is_deeply +MockOutput->get_info, [
destination => $engine->destination,
change => $dbchanges[-1]->format_name_with_tags,
)],
- [__ 'Will revert the following changes:'],
- ['lolz'],
[__ 'ok'],
], 'And the header and "ok" should be emitted';
+is_deeply +MockOutput->get_debug, [
+ [__ 'Will revert the following changes:'],
+ ['lolz'],
+], 'Output should show what will be reverted';
##############################################################################
# Test change_id_for_depend().