IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 14, 2006, 5:18:25 PM (20 years ago)
Author:
jhoblitt
Message:

add DataStore::FileSet->request

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DataStore/t/06_fileset.t

    r6540 r6587  
    33# Copyright (C) 2006  Joshua Hoblitt
    44#
    5 # $Id: 06_fileset.t,v 1.1 2006-03-08 00:23:09 jhoblitt Exp $
     5# $Id: 06_fileset.t,v 1.2 2006-03-15 03:18:25 jhoblitt Exp $
    66
    77use strict;
     
    1010use lib qw( ./lib ./t );
    1111
    12 use Test::More tests => 6;
     12use Test::More tests => 17;
    1313
    1414=head1 NAME
     
    7474# ->request()
    7575
     76use Net::HTTPServer;
     77
     78sub bar
     79{
     80    my $req = shift;             # Net::HTTPServer::Request object
     81    my $res = $req->Response();  # Net::HTTPServer::Response object
     82
     83    my $string = <<END;
     84# fileID      |bytes   |md5sum                          |type|chipname|
     85otis0123456.01|83002312|fe6a2b6564c0d4cfb3bbf1db813824ba|chip|ota01   |
     86otis0123456.02|83002312|a2b4a7d7b94dc6076c5f3f67239a48c6|chip|ota02   |
     87otis0123456.03|83002312|a39b1510484c7833e27454b181f13981|chip|ota03   |
     88otis0123456.04|83002312|7bb35e1e30f3f833c0416aea75f90304|chip|ota04   |
     89END
     90
     91    $res->Print($string);
     92
     93    return $res;
     94}
     95
     96$|++;
     97
     98$SIG{CHLD} = 'IGNORE';
     99my $pid = open(my $child, "-|");
     100
     101unless ($pid) {
     102    my $server = new Net::HTTPServer( port => 'scan' );
     103
     104    # send port number to parent
     105    print $server->Start(), "\n";
     106
     107    $server->RegisterURL('/', \&bar);
     108    $server->Process();  # Run forever
     109
     110    exit -1;
     111}
     112
     113my $port = <$child>;
     114chomp $port;
     115
     116{
     117    my $dsp = DataStore::FileSet->new(
     118        uri         => "http://localhost:$port/",
     119        fileset     => '12buckelyourshoe',
     120        datetime    => '2042-01-01T00:00:00Z',
     121        type        => 'foo',
     122    );
     123
     124    isa_ok($dsp->request, 'DataStore::Response');
     125}
     126
     127{
     128    my $dsp = DataStore::FileSet->new(
     129        uri         => "http://localhost:$port/",
     130        fileset     => '12buckelyourshoe',
     131        datetime    => '2042-01-01T00:00:00Z',
     132        type        => 'foo',
     133    );
     134
     135    my $dsr = $dsp->request;
     136
     137    ok($dsr->is_success, "response->is_success() is correct");
     138    is($dsr->code, 200, "response->code() is correct");
     139    is($dsr->status_line, "200 OK", "response->status_line() is correct");
     140    is(ref $dsr->data, 'ARRAY', "response->data is arrayref is correct");
     141    isa_ok($dsr->request, 'DataStore::Record');
     142
     143    my $data = $dsr->data;
     144    is(scalar @$data, 4, "data has the correct number of rows");
     145    isa_ok(@$data[0], 'DataStore::File', "data has correct type of rows");
     146    isa_ok(@$data[1], 'DataStore::File', "data has correct type of rows");
     147    isa_ok(@$data[2], 'DataStore::File', "data has correct type of rows");
     148    isa_ok(@$data[3], 'DataStore::File', "data has correct type of rows");
     149}
     150
     151# cleanup HTTP server
     152kill 9, $pid;
Note: See TracChangeset for help on using the changeset viewer.