fu: Close-up of Fu, bringing a scoop of water to her mouth (fu)fu ([staff profile] fu) wrote,
@ 2011-01-01 10:56 am UTC
  • Previous Entry
  • Add to Memories
  • Tell someone about this!
  • Next Entry
There's lots of nice stuff over at the Test::More documentation. In particular, I've just had a huge "D'OH" moment, and have switched to using is_deeply for many of my new tests where I check complex object structures. (Instead of, say, doing a for loop for each variable).


(2 comments) - (Post a new comment)
(Flat) (Top-level comments only)

foxfirefey: A guy looking ridiculous by doing a fashionable posing with a mouse, slinging the cord over his shoulders. (geek)


[personal profile] foxfirefey
2011-01-01 03:38 am UTC (link)
Interesting! Any examples?

(Reply to this)  (Thread


fu: Close-up of Fu, bringing a scoop of water to her mouth (fu)


[staff profile] fu
2011-01-01 03:49 am UTC (link)
Gladly! The examples are even from the same file :-D

Here's how I used to do it:
    my %contentfilters = (
        1 => {
            name => "first",
            sort => 1,
            public => 0
        },
        2 => {
            name => "incomplete"
        },
    );


    ( $res, $err ) = $do_request->( "getcircle", username => $u->user, includecontentfilters => 1 );
    is( scalar @{$res->{contentfilters}}, scalar keys %contentfilters, "Number of content filters match." );
    foreach my $filter ( @{$res->{contentfilters}} ) {
        my $id = $filter->{id};
        my $orig_filter = $contentfilters{$id};

        is( $filter->{name}, $orig_filter->{name} || "", "Filter name matches." );
        is( $filter->{public}, $orig_filter->{public} || 0, "Filter public setting matches." );
        is( $filter->{sortorder}, $orig_filter->{sort} || 0, "Filter sortorder matches." );
    }



And here's how I do it now:
    ( $res, $err ) = $do_request->( "checkfriends",
        username => $u->user,
    );
    $success->( "Checkfriends. Users have updated." );
    is_deeply( $res, {
            interval => 7,
            new => 0,
            lastupdate => LJ::mysql_time( $w2->timeupdate ),
    }, "No new entries." );

(Reply to this)  (Thread from start)  (Parent



(2 comments) - (Post a new comment)
(Flat) (Top-level comments only)