Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: How to syntax-check Catalyst code which throws 'Invalid CODE attributes' errors?

by Your Mother (Archbishop)
on Jun 10, 2021 at 03:28 UTC ( #11133717=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to syntax-check Catalyst code which throws 'Invalid CODE attributes' errors?
in thread How to syntax-check Catalyst code which throws 'Invalid CODE attributes' errors?

That’s punting a class of Catalyst errors though. Perl allows weird syntax in the “attributes” slot so you’ll only know if they’re bug-free if they go through Catalyst. I would always recommend using regular TAP style testing too. Every time you stray from standard practices you accrue unnecessary technical debt.

Example tests–

#!/usr/bin/env perl use strict; use warnings; use Test::More; use Catalyst::Test "MyApp"; # Closest to what you’re already doing. use_ok "MyApp::Controller::Foo"; # More what I would suggest because it’s testing how the # code is called and what it truly does. ok request("/foo")->is_success, "GET /foo is successful"; done_testing(2);

To get a full list of the action/path endpoints you might want to test, like /foo above, you can run–

env CATALYST_DEBUG=1 ./script/myapp_server.pl

You might have trouble if you have tightly coupled models or something. It’s easy to change the configuration to mock/test DBs though. The common way, but your app might not be set up that way, is to have a myapp_test.yml/myapp_test.conf file that overrides the production/deployment models or config (in myapp.yml/myapp.conf).

  • Comment on Re^3: How to syntax-check Catalyst code which throws 'Invalid CODE attributes' errors?
  • Select or Download Code

Replies are listed 'Best First'.
Re^4: How to syntax-check Catalyst code which throws 'Invalid CODE attributes' errors?
by bliako (Monsignor) on Jun 10, 2021 at 07:09 UTC

    I posted the above method as a *generic* means of nuking or mocking packages (thanks choroba) and, now it seems, pragmata. It's open to criticism with respect to its usage to this particular scenario, and Catalyst, of which I have no experience.

      Oh, I wasn’t trying to imply anything else. It was a great solution to do what the OP wants. I just don’t think what the OP wants is the best course for this case. And he asked about possible testing approaches in reply to my other node.

      Update, speling.

        sure, I am trying to make you criticise it more ! thanks

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11133717]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2022-01-24 20:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (65 votes). Check out past polls.

    Notices?