NAME

My::Module::Test - Test routines for Astro::SpaceTrack

SYNOPSIS

use Astro::SpaceTrack;

use lib qw{ inc };
use My::Module::Test;

my $st = Astro::SpaceTrack->new();

is_success $st, fubar => 42,
    'fubar( 42 ) succeeds';

my $resp = most_recent_http_response;
is $resp->content(), 'XLII',
    q<fubar( 42 ) returned 'XLII'>;

DESCRIPTION

This Perl module contains testing routines for Astro::SpaceTrack. Some of them actually perform tests, others perform whatever miscellany of functions seemed appropriate.

Everything in this module is private to the Astro::SpaceTrack package. The author reserves the right to change or revoke anything here without notice.

SUBROUTINES

This package exports the following subroutines, all by default.

is_error

is_error $st, fubar => 42,
    404,
    'Make sure $st->fubar( 42 ) returns a 404';

This subroutine executes the given method and tests its result code for numeric equality to the given code. The method is assumed to return an HTTP::Response object. The arguments are:

- The method's invocant
- The method's name
- Zero or more arguments
- The expected HTTP status code
- The test name

is_error_or_skip

is_error $st, fubar => 42,
    404,
    'Make sure $st->fubar( 42 ) returns a 404';

This subroutine is like is_error(), but if the returned status is 500, the test is skipped.

is_not_success

is_not_success $st, fubar => 42,
    'Make sure $st->fubar( 42 ) fails';

This subroutine executes the given method and tests its result for failure. The method is assumed to return an HTTP::Response object. The arguments are:

- The method's invocant
- The method's name
- Zero or more arguments
- The test name

is_success

is_success $st, fubar => 42,
    'Make sure $st->fubar( 42 ) succeeds';

This subroutine executes the given method and tests its result for success. The method is assumed to return an HTTP::Response object. The arguments are:

- The method's invocant
- The method's name
- Zero or more arguments
- The test name

is_success_or_skop

is_success_or_skip $st, fubar => 42,
    'Make sure $st->fubar( 42 ) succeeds', 3;

This subroutine is like is_success, but if a problem occurs the number of tests given by the last argument is skipped. The skip argument assumes that the current test is not skipped. If a 500 error is encountered, the current test is skipped, and the number of tests skipped is the skip argument plus 1.

last_modified

This subroutine returns the value of the Last-Modified header from the most recent HTTP::Respose object, as a Perl time. If there is no HTTP::Response, or if it did not contain that header, undef is returned.

most_recent_http_response

my $resp = most_recent_http_response;
$resp->is_success()
    or diag $resp->status_line();

This subroutine returns the HTTP::Response object from the most-recent test that actually generated one.

not_defined

not_defined $resp, 'Make sure we have a response';

This subroutine performs a test which succeeds its first argument is not defined. The second argument is the test name.

set_skip

set_skip 'celestrak.org';
set_skip 'celestrak.org', 'Manually skipping';

This subroutine sets or clears the skip indicator for the given site. The first argument is the site name, which must appear on the list supported by site_check. The second argument is optional and represents the skip message, if any.

site_check

site_check 'www.amsat.org', 'celestrak.org';

This subroutine tests a preselected URL on the given sites, and sets the skip indicator appropriately. Allowed site names are:

celestrak.org
mike.mccants
rod.sladen
www.amsat.org
www.space-track.org

spacetrack_user

If $ENV{SPACETRACK_USER} is not set, this subroutine sets it to whatever value is obtained from the identity file if available, or by prompting the user. The environment variable is not localized.

throws_exception

is_error $st, fubar => 666,
    'The exception of the beast',
    'Make sure $st->fubar( 666 ) throws the correct exception';

This subroutine executes the given method and succeeds if the method throws the expected exception. The arguments are:

- The method's invocant
- The method's name
- Zero or more arguments
- The expected exception
- The test name

The exception can be specified either as a Regexp object or as a scalar. In the latter case the scalar is expected to match at the beginning of the exception text.

SUPPORT

Support is by the author. Please file bug reports at https://github.com/trwyant/perl-Astro-SpaceTrack/issues or in electronic mail to the author.

AUTHOR

Thomas R. Wyant, III harryfmudd at comcast dot net

COPYRIGHT AND LICENSE

Copyright (C) 2014-2026 by Thomas R. Wyant, III

This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For more details, see the full text of the licenses in the files LICENSE-Artistic and LICENSE-GPL.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 481:

Unterminated C<...> sequence