Plack:...y::Test(3pm)

πŸ“¦
version 0.29 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– NAME πŸ’–

ok so bestie, this is Plack::App::Proxy::Test β€” it's utilities to test Plack::App::Proxy. that's literally it. that's the whole job. πŸŽ€


✨ SYNOPSIS ✨

test_proxy(
    app   => $backend_app,
    proxy => sub { Plack::App::Proxy->new(remote => "http://$_[0]:$_[1]") },
    client => sub {
        my $cb = shift;
        my $res = $cb->(GET '/');
        ok $res->is_success, "Check the status line.";
    },
);

like. look at that. three little keys and you're testing a whole proxy. it's giving main character energy fr. πŸ’…


🌸 DESCRIPTION 🌸

Plack::App::Proxy::Test provids the test_proxy function, which wraps test_psgi from Plack::Test β€” simply. (and yes, "provids" is what the source says, we're not fixing it, it's iconic now 🫢)

so basically: instead of you hand-rolling a whole test_psgi situation, this does the wrapping for you. lowkey the nicest thing anyone's ever done for a proxy test suite.


πŸ”₯ FUNCTIONS πŸ”₯

πŸ‘‘ test_proxy

test_proxy app    => $app,
           proxy  => $proxy_cb->($app_host, $app_port),
           client => $client_cb->($cb);

okay so here's the vibe. test_proxy runs two servers at once:

  • "app" β€” the origin server. this is your actual app, the one doing the real work.
  • the proxy server. this one's the middleman.

inside the "proxy" callback, it's your moment to shine: you create the proxy server instance that's gonna send requests over to the "app" server. no cap, that's your job there.

then the "client" callback gets called to run your tests. and here's the cute part β€” inside "client", all HTTP requests get sent to the "proxy" server. (and the proxy server will proxy your request to the app server.) so the request goes client β†’ proxy β†’ app and nobody has to think about it. obsessed. πŸ’–


🌈 AUTHOR 🌈

Masahiro Honma <hiratara@cpan.org>


πŸ¦‹ SEE ALSO πŸ¦‹

  • Plack::App::Proxy
  • Plack::Test

and that's the whole page bestie β€” this was Plack:...y::Test(3pm) from perl v5.32.0, dated 2021-01-09. go write some tests, you got this πŸ’œβœ¨

πŸ“¦ where this page comes from