<commit_before>use strict;
use warnings;
use Test::More tests => 6;
use Test::Exception;

use Mongo;

my $conn = Mongo::Connection->new;
isa_ok($conn, 'Mongo::Connection');

my $db = $conn->get_database('test_database');
isa_ok($db, 'Mongo::Database');

$db->drop;

my $coll = $db->get_collection('test');
my $id   = $coll->insert({ just => 'another', perl => 'hacker' });

ok((grep { $_ eq 'test' } $db->collection_names), 'collection_names');

is($coll->count, 1, 'count');
is($coll->find_one->{perl}, 'hacker', 'find_one');
is($coll->find_one->{_id}->value, $id->value, 'insert id');

END {
    $db->drop;
}<commit_msg>Test that failed commands throw an exception.<commit_after>use strict;
use warnings;
use Test::More tests => 7;
use Test::Exception;

use Mongo;

my $conn = Mongo::Connection->new;
isa_ok($conn, 'Mongo::Connection');

my $db = $conn->get_database('test_database');
isa_ok($db, 'Mongo::Database');

$db->drop;

my $coll = $db->get_collection('test');
my $id   = $coll->insert({ just => 'another', perl => 'hacker' });

ok((grep { $_ eq 'test' } $db->collection_names), 'collection_names');

is($coll->count, 1, 'count');
is($coll->find_one->{perl}, 'hacker', 'find_one');
is($coll->find_one->{_id}->value, $id->value, 'insert id');

throws_ok {
    $db->run_command({ foo => 'bar' });
} qr/no such cmd/;

END {
    $db->drop;
}
{'fraction_non_alphanumeric': 0.2344213649851632, 'fraction_numerical': 0.002967359050445104, 'mean_word_length': 5.516908212560386, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4957912', 'n_tokens_mistral': 516, 'n_tokens_neox': 502, 'n_words': 113}