#!perl

## Test that our SIGNATURE file is valid
## Will only run if the environment variable TEST_SIGNATURE is true
## Reference: https://metacpan.org/pod/Test::Signature

use 5.008001;
use strict;
use warnings;
use Test::More;

if (!$ENV{TEST_SIGNATURE}) {
    plan skip_all => 'Set the environment variable TEST_SIGNATURE to enable this test';
}
plan tests => 1;

SKIP: {
    if (!eval { require Module::Signature; 1 }) {
        skip ('Must have Module::Signature to test SIGNATURE file', 1);
    }
    elsif ( !-e 'SIGNATURE' ) {
        fail ('SIGNATURE file was not found');
    }
    elsif ( ! -s 'SIGNATURE') {
        fail ('SIGNATURE file was empty');
    }
    else {
        my $ret = Module::Signature::verify(skip=>1);
        if ($ret eq Module::Signature::SIGNATURE_OK()) {
            pass ('Valid SIGNATURE file');
        }
        else {
            fail ('Invalid SIGNATURE file');
        }
    }
}
