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 58     58   431 use strict;
  58         138  
  58         2017  
16 58     58   316 use warnings;
  58         127  
  58         2365  
17             package MongoDB::Op::_DropDatabase;
18              
19             # Implements a database drop; returns a MongoDB::CommandResult
20              
21 58     58   351 use version;
  58         122  
  58         470  
22             our $VERSION = 'v2.2.0';
23              
24 58     58   4998 use Moo;
  58         2375  
  58         428  
25              
26 58     58   21489 use MongoDB::Op::_Command;
  58         188  
  58         1602  
27              
28 58     58   357 use namespace::clean;
  58         159  
  58         508  
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;