File Coverage

blib/lib/App/Sqitch/Command/verify.pm
Criterion Covered Total %
statement 53 53 100.0
branch 4 4 100.0
condition 6 6 100.0
subroutine 12 12 100.0
pod 1 1 100.0
total 76 76 100.0


line stmt bran cond sub pod time code
1              
2             use 5.010;
3 2     2   1739 use strict;
  2         6  
4 2     2   12 use warnings;
  2         5  
  2         47  
5 2     2   11 use utf8;
  2         2  
  2         51  
6 2     2   9 use Moo;
  2         3  
  2         10  
7 2     2   50 use Types::Standard qw(Str HashRef);
  2         3  
  2         11  
8 2     2   683 use App::Sqitch::X qw(hurl);
  2         14  
  2         30  
9 2     2   1541 use Locale::TextDomain qw(App-Sqitch);
  2         10  
  2         18  
10 2     2   635 use List::Util qw(first);
  2         4  
  2         16  
11 2     2   379 use namespace::autoclean;
  2         5  
  2         123  
12 2     2   13  
  2         8  
  2         14  
13             extends 'App::Sqitch::Command';
14             with 'App::Sqitch::Role::ContextCommand';
15             with 'App::Sqitch::Role::ConnectingCommand';
16              
17             our $VERSION = 'v1.3.0'; # VERSION
18              
19             has target => (
20             is => 'ro',
21             isa => Str,
22             );
23              
24             has from_change => (
25             is => 'ro',
26             isa => Str,
27             );
28              
29             has to_change => (
30             is => 'ro',
31             isa => Str,
32             );
33              
34             has variables => (
35             is => 'ro',
36             isa => HashRef,
37             lazy => 1,
38             default => sub { {} },
39             );
40              
41             return qw(
42             target|t=s
43             from-change|from=s
44             to-change|to=s
45             set|s=s%
46             );
47             }
48              
49             my ( $class, $config, $opt ) = @_;
50              
51             my %params = map {
52             $_ => $opt->{$_}
53             } grep {
54             exists $opt->{$_}
55             } qw(target from_change to_change);
56              
57             if ( my $vars = $opt->{set} ) {
58             $params{variables} = $vars;
59             }
60              
61             return \%params;
62             }
63              
64             my ($self, $target) = @_;
65             my $cfg = $self->sqitch->config;
66             return (
67             %{ $cfg->get_section(section => 'core.variables') },
68 15     15   544 %{ $cfg->get_section(section => 'deploy.variables') },
69 15         242 %{ $cfg->get_section(section => 'verify.variables') },
70             %{ $target->variables }, # includes engine
71 15         56 %{ $self->variables }, # --set
72 15         36 );
73 15         35 }
74 15         237  
75 15         100 my $self = shift;
  15         489  
76             my ($targets, $changes) = $self->parse_args(
77             target => $self->target,
78             args => \@_,
79             );
80 10     10 1 20775  
81 10         54 # Warn on multiple targets.
82             my $target = shift @{ $targets };
83             $self->warn(__x(
84             'Too many targets specified; connecting to {target}',
85             target => $target->name,
86             )) if @{ $targets };
87 8         298  
  8         14  
88             # Warn on too many changes.
89             my $from = $self->from_change // shift @{ $changes };
90             my $to = $self->to_change // shift @{ $changes };
91 8 100       9 $self->warn(__x(
  8         22  
92             'Too many changes specified; verifying from "{from}" to "{to}"',
93             from => $from,
94 8   100     134 to => $to,
  5         14  
95 8   100     22 )) if @{ $changes };
  5         38  
96              
97             # Now get to work.
98             my $engine = $target->engine;
99             $engine->set_variables( $self->_collect_vars($target) );
100 8 100       12 $engine->verify($from, $to);
  8         20  
101             return $self;
102             }
103 8         577  
104 8         1110 1;
105 8         140  
106 8         245  
107             =head1 Name
108              
109             App::Sqitch::Command::verify - Verify deployed Sqitch changes
110              
111             =head1 Synopsis
112              
113             my $cmd = App::Sqitch::Command::verify->new(%params);
114             $cmd->execute;
115              
116             =head1 Description
117              
118             If you want to know how to use the C<verify> command, you probably want to be
119             reading C<sqitch-verify>. But if you really want to know how the C<verify> command
120             works, read on.
121              
122             =head1 Interface
123              
124             =head2 Class Methods
125              
126             =head3 C<options>
127              
128             my @opts = App::Sqitch::Command::verify->options;
129              
130             Returns a list of L<Getopt::Long> option specifications for the command-line
131             options for the C<verify> command.
132              
133             =head2 Attributes
134              
135             =head3 C<onto_change>
136              
137             Change onto which to rebase the target.
138              
139             =head3 C<target>
140              
141             The verify target database URI.
142              
143             =head3 C<from_change>
144              
145             Change from which to verify changes.
146              
147             =head3 C<to_change>
148              
149             Change up to which to verify changes.
150              
151             =head2 Instance Methods
152              
153             =head3 C<execute>
154              
155             $verify->execute;
156              
157             Executes the verify command.
158              
159             =head1 See Also
160              
161             =over
162              
163             =item L<sqitch-verify>
164              
165             Documentation for the C<verify> command to the Sqitch command-line client.
166              
167             =item L<sqitch>
168              
169             The Sqitch command-line client.
170              
171             =back
172              
173             =head1 Author
174              
175             David E. Wheeler <david@justatheory.com>
176              
177             =head1 License
178              
179             Copyright (c) 2012-2022 iovation Inc., David E. Wheeler
180              
181             Permission is hereby granted, free of charge, to any person obtaining a copy
182             of this software and associated documentation files (the "Software"), to deal
183             in the Software without restriction, including without limitation the rights
184             to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
185             copies of the Software, and to permit persons to whom the Software is
186             furnished to do so, subject to the following conditions:
187              
188             The above copyright notice and this permission notice shall be included in all
189             copies or substantial portions of the Software.
190              
191             THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
192             IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
193             FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
194             AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
195             LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
196             OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
197             SOFTWARE.
198              
199             =cut