#!perl -T
use strict;
use warnings;
use Test::More;

plan skip_all => "DBIx::Fast No test POD" unless $ENV{'DBIX_FAST_TEST'};

eval "use Test::Pod 1.52";
plan skip_all => "Test::Pod 1.52 required for testing POD" if $@;

eval "use Test::Pod::Coverage 1.10";
plan skip_all => "Test::Pod::Coverage 1.10 required for testing POD coverage" if $@;

eval "use Pod::Coverage 0.23";
plan skip_all => "Pod::Coverage 0.23 required for testing POD coverage" if $@;

# Object::Pad auto-generates DOES, META, new and accessor methods.
# Exclude them from coverage checks along with private methods.
my $trustme = { trustme => [qr/^(DOES|META|new|DESTROY)$/] };

# Also trust accessor/reader methods generated by :accessor/:reader
my %also_private = (
    'DBIx::Fast' => {
        trustme => [qr/^(DOES|META|new|DESTROY|extra_args)$/],
        also_private => [qr/^_/],
    },
    'DBIx::Fast::Base' => $trustme,
    'DBIx::Fast::Schema' => {
        trustme => [qr/^(DOES|META|new|DESTROY|get_indexs)$/],
    },
    'DBIx::Fast::Transaction' => {
        trustme => [qr/^(DOES|META|new|DESTROY|level|savepoints|start_time|stats)$/],
    },
    'DBIx::Fast::Profiler' => {
        trustme => [qr/^(DOES|META|new|DESTROY|auto_print|enabled|max_queries|queries|slow_query)$/],
    },
    'DBIx::Fast::Profile::Base' => {
        trustme => [qr/^(DOES|META|new|DESTROY|dbix|enabled|slow_query)$/],
    },
    'DBIx::Fast::Profile::MariaDB' => {
        trustme => [qr/^(DOES|META|new|DESTROY|get_connection_status|get_connection_usage|get_connection_variables|get_current_connections|get_processes)$/],
    },
    'DBIx::Fast::Profile::SQLite' => {
        trustme => [qr/^(DOES|META|new|DESTROY|init|get_slow_queries|get_query_profile|get_stats|print_stats|explain_query|get_table_stats|get_index_stats|analyze_indexes|print_index_analysis|get_index_metrics|monitor_connections|get_current_connections|get_processes|print_connection_monitor|start_connection_monitor)$/],
    },
);

for my $module (sort keys %also_private) {
    pod_coverage_ok($module, $also_private{$module}, "Pod coverage on $module");
}

done_testing();
