Changeset 345

Show
Ignore:
Timestamp:
01/06/07 20:52:25 (2 years ago)
Author:
miya
Message:

Assurer: Create Assurer::Test and Assurer::Plugin::HTTP uses this class.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • library/perl/trunk/Assurer/examples/config.yaml

    r343 r345  
     1global: 
     2  config: 
     3    no_diag: 1 
     4 
    15plugins: 
    26  - module: HTTP 
     7    name: http://svn.mizzy.org/ #0 
    38    config: 
    49      url: http://svn.mizzy.org/ 
    510      match: It works! 
     11 
     12  - module: HTTP 
     13    name: http://svn.mizzy.org/ #1 
     14    config: 
     15      url: http://svn.mizzy.org/ 
     16      match: It not works! 
  • library/perl/trunk/Assurer/lib/Assurer.pm

    r343 r345  
    4747        $class->use or die $@; 
    4848 
    49         $class->new({ config => $plugin->{config} })->run; 
     49        $class->new({ 
     50            config => $plugin->{config}, 
     51            name   => $plugin->{name}, 
     52        })->run; 
    5053    } 
     54} 
     55 
     56sub log { 
     57    my ($self, $level, $msg) = @_; 
     58    warn "[$level] $msg\n"; 
    5159} 
    5260 
  • library/perl/trunk/Assurer/lib/Assurer/Plugin.pm

    r343 r345  
    33use strict; 
    44use warnings; 
     5use UNIVERSAL::require; 
    56 
    67sub new { 
    78    my ( $class, $args ) = @_; 
    89 
    9     my $self = { 
    10         config => $args->{config}, 
    11     }; 
     10    my $self = { %$args }; 
    1211 
    1312    bless $self, $class; 
     13 
     14    my $name = $self->{name} || 'no name'; 
     15    $self->log('info', "Testing $name"); 
     16    return $self; 
     17} 
     18 
     19sub log { 
     20    my $self = shift; 
     21    Assurer->context->log(@_); 
    1422} 
    1523 
  • library/perl/trunk/Assurer/lib/Assurer/Plugin/HTTP.pm

    r343 r345  
    33use strict; 
    44use warnings; 
    5 use Test::More tests => 1; 
    65use base qw( Assurer::Plugin ); 
     6use Assurer::Test; 
    77use LWP::Simple; 
    88 
     
    1010    my $self = shift; 
    1111 
    12     like ( get($self->{config}->{url}), qr/$self->{config}->{match}/ ); 
     12    my $url   = $self->{config}->{url}; 
     13    my $match = $self->{config}->{match}; 
     14    like ( 
     15        get($url), 
     16        qr/$match/, 
     17        "Content of $url matches '$match'", 
     18    ); 
    1319} 
    1420