<commit_before>use lib 'lib';
use Play::Test;
use parent qw(Test::Class);

use Play::DB qw(db);

sub setup :Test(setup) {
    reset_db();
}

sub add :Tests {
    db->users->add({ login => $_, realms => ['europe'] }) for qw( foo );
    my $quest = db->quests->add({
        name => 'quest name',
        team => ['foo'],
        status => 'open',
        realm => 'europe',
        description => "Blah\n\nBlah.",
    });
    cmp_deeply $quest, superhashof({
        _id => re('^\w+$'),
        ts => re('^\d+$'),
        name => 'quest name',
        status => 'open',
        team => ['foo'],
        realm => 'europe',
        description => "Blah\n\nBlah.",
    });
}

sub add_check_user :Tests {
    like exception {<commit_msg>test that leaving out quest.description and quest.status is ok<commit_after>use lib 'lib';
use Play::Test;
use parent qw(Test::Class);

use Play::DB qw(db);

sub setup :Test(setup) {
    reset_db();
}

sub add :Tests {
    db->users->add({ login => $_, realms => ['europe'] }) for qw( foo );
    my $quest = db->quests->add({
        name => 'quest name',
        team => ['foo'],
        status => 'open',
        realm => 'europe',
        description => "Blah\n\nBlah.",
    });
    cmp_deeply $quest, superhashof({
        _id => re('^\w+$'),
        ts => re('^\d+$'),
        name => 'quest name',
        status => 'open',
        team => ['foo'],
        realm => 'europe',
        description => "Blah\n\nBlah.",
    });

    # no description, no status
    $quest = db->quests->add({
        name => 'quest name 2',
        team => ['foo'],
        realm => 'europe',
    });
    cmp_deeply $quest, superhashof({
        _id => re('^\w+$'),
        ts => re('^\d+$'),
        name => '<NAME>',
        status => 'open',
        team => ['foo'],
        realm => 'europe',
    });
}

sub add_check_user :Tests {
    like exception {
{'fraction_non_alphanumeric': 0.20982381206620396, 'fraction_numerical': 0.0005339028296849973, 'mean_word_length': 2.1026490066225167, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 51, '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': '7275360', 'n_tokens_mistral': 637, 'n_tokens_neox': 632, 'n_words': 161}