diff options
author | Brian C. Duggan <brian@bestpractical.com> | 2018-03-13 22:46:48 -0400 |
---|---|---|
committer | Brian C. Duggan <brian@bestpractical.com> | 2018-03-14 22:14:21 -0400 |
commit | 0d63b7bfe5c221004840bb9fda8556446e3c7acf (patch) | |
tree | 8584785314bcce78606d537648c8ec898f10f034 | |
parent | 6f88de454c0e6167a3cc174a4c4118fee8826af1 (diff) |
Use GnuPG::Interface branch-checking methods in tests
Replace gpg version and branch checking functions defined and used in
the tests with GnuPG::Interface class methods.
-rw-r--r-- | t/MyTestSpecific.pm | 9 | ||||
-rw-r--r-- | t/get_secret_keys.t | 6 | ||||
-rw-r--r-- | t/list_secret_keys.t | 6 |
3 files changed, 7 insertions, 14 deletions
diff --git a/t/MyTestSpecific.pm b/t/MyTestSpecific.pm index 809d55c..1599949 100644 --- a/t/MyTestSpecific.pm +++ b/t/MyTestSpecific.pm @@ -30,13 +30,13 @@ use GnuPG::Handles; use vars qw( @ISA @EXPORT $stdin $stdout $stderr $gpg_program $handles $gnupg - %texts $gpg_is_modern + %texts ); @ISA = qw( Exporter ); @EXPORT = qw( stdin stdout stderr gnupg_program handles reset_handles - texts file_match gpg_is_modern + texts file_match ); $gnupg = GnuPG::Interface->new( passphrase => 'test' ); @@ -54,11 +54,6 @@ if (-f "test/gnupghome") { $record->close(); } -my @version = split('\.', $gnupg->version()); -$gpg_is_modern = ($version[0] > 2 || ($version[0] == 2 && $version[1] >= 1)); - - - $gnupg->options->hash_init( homedir => $homedir, armor => 1, meta_interactive => 0, diff --git a/t/get_secret_keys.t b/t/get_secret_keys.t index a7f1348..b370e57 100644 --- a/t/get_secret_keys.t +++ b/t/get_secret_keys.t @@ -45,7 +45,7 @@ TEST usage_flags => 'scaESCA', pubkey_data => $pubkey_data, }; - if (!$gpg_is_modern) { + if (!$gnupg->is_modern) { # older versions don't report ownertrust or pubkey_data for secret keys: delete $args->{pubkey_data}; $args->{owner_trust} = ''; @@ -91,7 +91,7 @@ TEST pubkey_data => $subkey_pub_data, }; - if (!$gpg_is_modern) { + if (!$gnupg->is_modern) { # older versions do not report pubkey data for secret keys delete $sub_args->{pubkey_data}; } @@ -105,7 +105,7 @@ TEST $handmade_key->push_subkeys( $subkey ); # older versions do not report designated revokers for secret keys - $handmade_key->push_revokers( $revoker ) if ($gpg_is_modern); + $handmade_key->push_revokers( $revoker ) if ($gnupg->is_modern); $handmade_key->compare( $given_key ); }; diff --git a/t/list_secret_keys.t b/t/list_secret_keys.t index 8e3c911..ed6430f 100644 --- a/t/list_secret_keys.t +++ b/t/list_secret_keys.t @@ -23,7 +23,7 @@ TEST $outfile = 'test/secret-keys/1.out'; my $out = IO::File->new( "> $outfile" ) or die "cannot open $outfile for writing: $ERRNO"; - my $seckey_file = $gpg_is_modern ? 'pubring.kbx' : 'secring.gpg'; + my $seckey_file = $gnupg->is_modern ? 'pubring.kbx' : 'secring.gpg'; my $pubring_line = $gnupg->options->homedir() . '/' . $seckey_file . "\n"; while (<$stdout>) { if ($_ eq $pubring_line) { @@ -44,9 +44,7 @@ TEST TEST { - my $suffix = '0'; - $suffix = 'modern' if ($gpg_is_modern); - my @files_to_test = ( 'test/secret-keys/1.'.$suffix.'.test' ); + my @files_to_test = ( 'test/secret-keys/1.'.$gnupg->branch.'.test' ); return file_match( $outfile, @files_to_test ); }; |