File Coverage

blib/lib/MongoDB/Op/_DropDatabase.pm
Criterion Covered Total %
statement 18 24 75.0
branch 0 2 0.0
condition n/a
subroutine 6 7 85.7
pod 0 1 0.0
total 24 34 70.5


line stmt bran cond sub pod time code
1             # Copyright 2016 - present MongoDB, Inc.
2             #
3             # Licensed under the Apache License, Version 2.0 (the "License");
4             # you may not use this file except in compliance with the License.
5             # You may obtain a copy of the License at
6             #
7             # http://www.apache.org/licenses/LICENSE-2.0
8             #
9             # Unless required by applicable law or agreed to in writing, software
10             # distributed under the License is distributed on an "AS IS" BASIS,
11             # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12             # See the License for the specific language governing permissions and
13             # limitations under the License.
14              
15 59     59   423 use strict;
  59         135  
  59         1955  
16 59     59   341 use warnings;
  59         131  
  59         2401  
17             package MongoDB::Op::_DropDatabase;
18              
19             # Implements a database drop; returns a MongoDB::CommandResult
20              
21 59     59   339 use version;
  59         2353  
  59         461  
22             our $VERSION = 'v2.2.1';
23              
24 59     59   5248 use Moo;
  59         151  
  59         419  
25              
26 59     59   21254 use MongoDB::Op::_Command;
  59         163  
  59         1665  
27              
28 59     59   415 use namespace::clean;
  59         174  
  59         444  
29              
30             with $_ for qw(
31             MongoDB::Role::_PrivateConstructor
32             MongoDB::Role::_DatabaseOp
33             MongoDB::Role::_WriteOp
34             );
35              
36             sub execute {
37 0     0 0   my ( $self, $link ) = @_;
38              
39             my $op = MongoDB::Op::_Command->_new(
40             db_name => $self->db_name,
41             query => [
42             dropDatabase => 1,
43 0 0         ( $link->supports_helper_write_concern ? ( @{ $self->write_concern->as_args } ) : () ),
  0            
44             ],
45             query_flags => {},
46             bson_codec => $self->bson_codec,
47             session => $self->session,
48             monitoring_callback => $self->monitoring_callback,
49             );
50              
51 0           my $res = $op->execute($link);
52 0           $res->assert_no_write_concern_error;
53              
54 0           return $res;
55             }
56              
57             1;