Bluesky
view release on metacpan or search on metacpan
t/000_compile.t view on Meta::CPAN
root => {
cid => 'bafyreiahl3awi5qmakvgbogi3dhj5ji5vq7xeyye4fkznx6fm4o75vlmx4',
uri => bless(
{ hash => '',
host => 'did:plc:tpg43qhh4lw4ksiffs4nbda3',
pathname => '/app.bsky.feed.post/3lbzupvurts2j',
searchParams => bless( [], 'At::Protocol::URI::_query' ),
},
'At::Protocol::URI'
)
}
},
'reply';
};
my $login;
subtest auth => sub {
my $path = path(__FILE__)->sibling('test_auth.json')->realpath; # Public and totally worthless auth info
skip_all 'failed to locate auth data' unless $path->exists;
my $auth = decode_json $path->slurp_utf8;
subtest auth => sub {
subtest resume => sub {
skip_all 'no session to resume' unless keys %{ $auth->{resume} };
my $todo = todo 'Working with live services here. Things might not go as we expect or hope...';
ok $login = $bsky->resume( $auth->{resume}{accessJwt}, $auth->{resume}{refreshJwt} ), 'resume session for the following tests';
};
subtest login => sub {
skip_all 'resumed session; no login required' if $login;
skip_all 'no auth info found' unless keys %{ $auth->{login} };
my $todo = todo 'Working with live services here. Things might not go as we expect or hope...';
ok $login = $bsky->login( $auth->{login}{identifier}, $auth->{login}{password} ), 'logging in for the following tests';
#~ ddx $bsky->session;
};
};
subtest 'Feeds and content' => sub {
$login || skip_all "$login";
is my $tt = $bsky->getTrendingTopics(), hash {
field suggested => bag {
all_items hash {
field description => E();
field displayName => E();
field link => D();
field topic => D();
end;
};
end
};
field topics => bag {
all_items hash {
field description => E();
field displayName => E();
field link => D();
field topic => D();
end;
};
end
};
end
}, 'getTrendingTopics( ... )';
is my $timeline = $bsky->getTimeline(), hash {
field cursor => D();
field feed => D(); # Feed items are subject to change
end;
}, 'getTimeline( )';
is my $authorFeed = $bsky->getAuthorFeed( actor => 'bsky.app' ), hash {
field cursor => E();
field feed => D(); # Feed items are subject to change
end;
}, 'getAuthorFeed( ... )';
is my $postThread = $bsky->getPostThread( uri => 'at://bsky.app/app.bsky.feed.post/3l6oveex3ii2l' ), hash {
field thread => D();
field threadgate => E();
end;
}, 'getPostThread( ... )';
is my $stable_post = $bsky->getPost('at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.post/3l6oveex3ii2l'), hash {
field author => D();
field cid => D();
field embed => E();
field indexedAt => D();
field labels => D();
field likeCount => D();
field quoteCount => D();
field record => D();
field replyCount => D();
field repostCount => D();
field threadgate => E();
field uri => D();
field viewer => D();
field bookmarkCount => D();
field debug => E();
end;
}, 'getPost( ... )';
is $bsky->getPost('at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.post/3l6oveex3ii20'), U(), 'getPost( ... ) with bad uri';
is my $posts = $bsky->getPosts(
'at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.post/3l6oveex3ii2l',
'at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.post/3lbvgvbvcf22c'
),
array {
item 0 => D();
item 1 => D();
end;
}, 'getPosts( ... )';
is my $likes = $bsky->getLikes( uri => 'at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.post/3l6oveex3ii2l' ), hash {
field cid => E();
field likes => array {etc};
field uri => D();
field cursor => E();
end
}, 'getLikes( ... )';
#~ ddx $likes;
#~ p my $ys = $bsky->getLikes( uri => 'at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.post/3l6oveex3ii2l' );
my $post;
subtest createPost => sub {
is $post = $bsky->createPost( text => 'Post is for #testing only. @atproto.bsky.social https://wikipedia.com/' ), hash {
field cid => D();
field commit => hash {
field cid => D();
field rev => D();
end;
};
field uri => D();
field validationStatus => D();
end;
}, 'plain text';
is my $reply = $bsky->createPost( reply_to => $post->{uri}, text => <<'END' ),
Just another test.
This isn't a hashtag but #this is! This is a double ##hashtag.
ããã«ã¡ã¯
END
hash {
field cid => D();
field commit => hash {
field cid => D();
field rev => D();
end;
};
field uri => D();
field validationStatus => D();
end;
}, 'reply to text post';
my $img = HTTP::Tiny->new->get('https://picsum.photos/500/300');
#~ use Data::Dump;
#~ ddx $img;
skip 1 unless $img->{success};
is my $image_reply = $bsky->createPost(
reply_to => $post->{uri},
embed => { images => [ { image => $img->{content}, alt => 'Lorem Picsum', mime => $img->{headers}{'content-type'} } ] },
text => <<'END' ),
Yet another test.
But with an image this time!
END
hash {
field cid => D();
field commit => hash {
field cid => D();
field rev => D();
end;
};
field uri => D();
field validationStatus => D();
end;
}, 'reply with image';
( run in 1.713 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )