/
revert.t
61 lines (48 loc) · 1.31 KB
/
revert.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/perl
use strict;
use warnings;
use v5.10;
use Test::More;
use App::Sqitch;
use Path::Class qw(dir file);
use Test::MockModule;
use Test::Exception;
use lib 't/lib';
use MockOutput;
my $CLASS = 'App::Sqitch::Command::revert';
require_ok $CLASS or die;
isa_ok $CLASS, 'App::Sqitch::Command';
can_ok $CLASS, qw(
options
configure
new
to_target
execute
);
my $sqitch = App::Sqitch->new(
plan_file => file(qw(t sql sqitch.plan)),
top_dir => dir(qw(t sql)),
_engine => 'sqlite',
);
isa_ok my $revert = $CLASS->new(sqitch => $sqitch), $CLASS;
is $revert->to_target, undef, 'to_target should be undef';
# Mock the engine interface.
my $mock_engine = Test::MockModule->new('App::Sqitch::Engine::sqlite');
my @args;
$mock_engine->mock(revert => sub { shift; @args = @_ });
ok $revert->execute('@alpha'), 'Execute to "@alpha"';
is_deeply \@args, ['@alpha'],
'"@alpha" and "all" should be passed to the engine';
@args = ();
ok $revert->execute, 'Execute';
is_deeply \@args, [undef],
'undef and "all" should be passed to the engine';
isa_ok $revert = $CLASS->new(
sqitch => $sqitch,
to_target => 'foo',
), $CLASS, 'Object with to';
@args = ();
ok $revert->execute, 'Execute again';
is_deeply \@args, ['foo'],
'"foo" and "tag" should be passed to the engine';
done_testing;