Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Migrating Code From Test to Production: How to do it right, how to set up an environment that leaves nothing to chance

by Herkum (Parson)
on Jul 11, 2006 at 13:30 UTC ( #560450=note: print w/replies, xml ) Need Help??


in reply to Migrating Code From Test to Production: How to do it right, how to set up an environment that leaves nothing to chance

I wrote a bunch of tests that depended on a database for holding my data. The tests deleted all the rows from the tables that I was working with and then inserting the test data into the tables. If I did this against the production database I was going to delete the production data as well, that would be bad.

I decided to have a production and a test database. I wanted something that would be easy to include in my test code and would not require a major change in production code. I thought, if I am working with my test modules I make my DB connection code look like this what would I have to do.

use Base::DB::Connect 'test';

The only thing I had to do was include a import subroutine/method. It changed the $database variable from 'Prod' to 'Test' and I was done! I was happy because I did not have to change the code to support 'Test' and 'Production' as separate environments.

  • Comment on Re: Migrating Code From Test to Production: How to do it right, how to set up an environment that leaves nothing to chance
  • Download Code

Replies are listed 'Best First'.
Re^2: Migrating Code From Test to Production: How to do it right, how to set up an environment that leaves nothing to chance
by tphyahoo (Vicar) on Jul 14, 2006 at 09:58 UTC
    What is an "import" subroutine? Why did you boldface this term? Does it have a special meaning?

    What terms do I search the web on to learn more?

      It has to do with the use function, which is really just syntactic sugar. One of the things it does is to call the static import method on the package youíre loading, passing it the parameters you gave on the use line to process them. The common behaviour of import is to export functions from the package itís in into your current one, usually by calling upon Exporter. However, all of that is entirely conventional, and you can actually do whatever you want with those parameters Ė like using them as a names for configurations to choose between, as Herkum does.

      The use docs have the details.

      Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://560450]
help
Chatterbox?
LanX hurts to be bitten between the legs ;-)
[holli]: You see, I have a friend whose daughter has been damaged seriously because she wasn't vaccinated against measles. (Her mother being anti-vaxx).
[LanX]: Contrary to Olivia newton John I don't like physical confrontations ...
[LanX]: Oh, you spread measles in your saliva?
[LanX]: ... and why did you bite hos daughter?
[LanX]: *his
[holli]: And this guy was also Anti-Vaxx and I just snapped. I shoed him all over the yard
[james28909]: biting between the legs? now thats my kind of religion.
[holli]: and back into the building, saw him later peeking out of the window looking scared. It was hilarious.
[LanX]: Let's get physical...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (12)
As of 2017-12-13 18:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (373 votes). Check out past polls.

    Notices?