SlideShare a Scribd company logo
1 of 21
Download to read offline
Introduction                      Test::DBIx::Class::Schema       Future        Finally




                           Mostly Lazy DBIx::Class Testing

                                                Chisel Wright

                                                   Net-A-Porter


                                                       2011




Mostly Lazy DBIx::Class Testing                                            Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




In A Nutshell




                            DBIx::Class schema sanity checking tests




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




Why?




                          Ongoing Quest To Be As LAZY As Possible




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




Non-Lazy



       # are specific columns defined?

       my $thingy = $model->resultset(’BigBagOfFail’);

       my @columns = qw/id name department/);

       can_ok($thingy, @columns);




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




Non-Lazy


       foreach my $column (@columns) {
         try {
           $thingy->$column();
           ok("called $column()");
         }
         catch($e) {
           diag $e;
           fail("$column() failed");
         }
       }



Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




Non-Lazy




       What about . . . ?
               relationships
               custom methods




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




Non-Lazy




               Decide to test something new?
               How many .t files do you need to edit?
               More than zero?
               Too much work!!




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema      Future        Finally




Getting Lazy




                                     Test::DBIx::Class::Schema




Mostly Lazy DBIx::Class Testing                                           Net-A-Porter
Introduction                      Test::DBIx::Class::Schema     Future        Finally




Test::DBIx::Class::Schema




                                       My Attempt At Laziness




Mostly Lazy DBIx::Class Testing                                          Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future         Finally




An example (setup)



       my $schematest              = Test::DBIx::Class::Schema->new({
         # required
         dsn        =>             ’dbi:Pg:dbname=mydb’,
         namespace =>              ’MyDB::Schema’,
         moniker    =>             ’SomeTable’,
         # optional
         username =>               ’some_user’,
         password =>               ’opensesame’,
       });




Mostly Lazy DBIx::Class Testing                                         Net-A-Porter
Introduction                       Test::DBIx::Class::Schema   Future        Finally




An example (config)


       # tell it what to test
       $schematest->methods({
         columns    => [ qw( id name ) ],

           relations              => [ qw( foo ) ],

           custom                 => [ qw( some_method ) ],

         resultsets => [ qw( ) ],
       });



Mostly Lazy DBIx::Class Testing                                         Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




An example (running)




       $schematest->run_tests();




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




You get. . .




               can ok( @columns )
               can ok( @relations )
               can ok( @customs ) # row subs
               can ok( @resultsets ) # rs subs




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




You also get. . .



               $thing->$column called ok
               $thing->$relation called ok
               test that $column exists in the database
               ensure related-source exists
               test self.* and foreign.* columns for relationships
               test proxied relationships
               PASS/FAIL for relationship validity




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




You don’t get




                             Functional Testing



Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




Benefits




               only maintaining a list (or three)
               lots of sanity checking
               find out if someone deletes columns from the database
               upgrading ’TDCS’ improves *.t files for free




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




Recommendations




               Test one table/class per file
               Use Test::Aggregate
               Factor out ->new call for $schema




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema     Future        Finally




In The Real World




               on the CPAN since 2008
               used in production code since 2009
               recent burst of improvements
                      never used to test empty tables - OOPS!
                      used to be quite basic




Mostly Lazy DBIx::Class Testing                                          Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




Did It Work?




                                                  YES!
                                                   IMNSHO




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




What Next?




       Wishlist
               relationship reciprocity
               relationships that are coderefs
               db columns that aren’t in the schema?
               tie-in with DBIx::Class::Schema::Loader




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                       Test::DBIx::Class::Schema   Future        Finally




End Credits



                                   QUESTIONS?
       Me:
               chisel.wright@net-a-porter.com
               CPANID: CHISEL
               github:            github.com/chiselwright
       Module:
               metacpan.org/release/Test-DBIx-Class-Schema
               github.com/chiselwright/test-dbix-class-schema


Mostly Lazy DBIx::Class Testing                                         Net-A-Porter

More Related Content

What's hot

Java 8 selected updates
Java 8 selected updatesJava 8 selected updates
Java 8 selected updatesVinay H G
 
Refactoring to Scala DSLs and LiftOff 2009 Recap
Refactoring to Scala DSLs and LiftOff 2009 RecapRefactoring to Scala DSLs and LiftOff 2009 Recap
Refactoring to Scala DSLs and LiftOff 2009 RecapDave Orme
 
OOP with Java - Abstract Classes and Interfaces
OOP with Java - Abstract Classes and InterfacesOOP with Java - Abstract Classes and Interfaces
OOP with Java - Abstract Classes and InterfacesHitesh-Java
 
Session 02 - Elements of Java Language
Session 02 - Elements of Java LanguageSession 02 - Elements of Java Language
Session 02 - Elements of Java LanguagePawanMM
 
A Brief, but Dense, Intro to Scala
A Brief, but Dense, Intro to ScalaA Brief, but Dense, Intro to Scala
A Brief, but Dense, Intro to ScalaDerek Chen-Becker
 
Exception Handling - Continued
Exception Handling - Continued Exception Handling - Continued
Exception Handling - Continued Hitesh-Java
 
Scala in practice
Scala in practiceScala in practice
Scala in practiceTomer Gabel
 
Session 09 - OOP with Java - Part 3
Session 09 - OOP with Java - Part 3Session 09 - OOP with Java - Part 3
Session 09 - OOP with Java - Part 3PawanMM
 
Review Session and Attending Java Interviews
Review Session and Attending Java Interviews Review Session and Attending Java Interviews
Review Session and Attending Java Interviews Hitesh-Java
 
Session 01 - Introduction to Java
Session 01 - Introduction to JavaSession 01 - Introduction to Java
Session 01 - Introduction to JavaPawanMM
 
Session 10 - OOP with Java - Abstract Classes and Interfaces
Session 10 - OOP with Java - Abstract Classes and InterfacesSession 10 - OOP with Java - Abstract Classes and Interfaces
Session 10 - OOP with Java - Abstract Classes and InterfacesPawanMM
 
Core Java Basics
Core Java BasicsCore Java Basics
Core Java BasicsFayis-QA
 
From code to pattern, part one
From code to pattern, part oneFrom code to pattern, part one
From code to pattern, part oneBingfeng Zhao
 
Rapid Application Development using Ruby on Rails
Rapid Application Development using Ruby on RailsRapid Application Development using Ruby on Rails
Rapid Application Development using Ruby on RailsSimobo
 

What's hot (17)

Java 8 selected updates
Java 8 selected updatesJava 8 selected updates
Java 8 selected updates
 
Refactoring to Scala DSLs and LiftOff 2009 Recap
Refactoring to Scala DSLs and LiftOff 2009 RecapRefactoring to Scala DSLs and LiftOff 2009 Recap
Refactoring to Scala DSLs and LiftOff 2009 Recap
 
OOP with Java - Abstract Classes and Interfaces
OOP with Java - Abstract Classes and InterfacesOOP with Java - Abstract Classes and Interfaces
OOP with Java - Abstract Classes and Interfaces
 
Oop lecture3
Oop lecture3Oop lecture3
Oop lecture3
 
Session 02 - Elements of Java Language
Session 02 - Elements of Java LanguageSession 02 - Elements of Java Language
Session 02 - Elements of Java Language
 
Java OOPs
Java OOPs Java OOPs
Java OOPs
 
A Brief, but Dense, Intro to Scala
A Brief, but Dense, Intro to ScalaA Brief, but Dense, Intro to Scala
A Brief, but Dense, Intro to Scala
 
Exception Handling - Continued
Exception Handling - Continued Exception Handling - Continued
Exception Handling - Continued
 
Scala in practice
Scala in practiceScala in practice
Scala in practice
 
Session 09 - OOP with Java - Part 3
Session 09 - OOP with Java - Part 3Session 09 - OOP with Java - Part 3
Session 09 - OOP with Java - Part 3
 
Review Session and Attending Java Interviews
Review Session and Attending Java Interviews Review Session and Attending Java Interviews
Review Session and Attending Java Interviews
 
Session 01 - Introduction to Java
Session 01 - Introduction to JavaSession 01 - Introduction to Java
Session 01 - Introduction to Java
 
Session 10 - OOP with Java - Abstract Classes and Interfaces
Session 10 - OOP with Java - Abstract Classes and InterfacesSession 10 - OOP with Java - Abstract Classes and Interfaces
Session 10 - OOP with Java - Abstract Classes and Interfaces
 
Core Java Basics
Core Java BasicsCore Java Basics
Core Java Basics
 
From code to pattern, part one
From code to pattern, part oneFrom code to pattern, part one
From code to pattern, part one
 
Rapid Application Development using Ruby on Rails
Rapid Application Development using Ruby on RailsRapid Application Development using Ruby on Rails
Rapid Application Development using Ruby on Rails
 
Viva file
Viva fileViva file
Viva file
 

Viewers also liked

Frezza_Christine_Macy’s_classification_of_costume_jewelry
Frezza_Christine_Macy’s_classification_of_costume_jewelryFrezza_Christine_Macy’s_classification_of_costume_jewelry
Frezza_Christine_Macy’s_classification_of_costume_jewelryChristine Frezza
 
Fashion Marketing Week 2
Fashion Marketing Week 2Fashion Marketing Week 2
Fashion Marketing Week 2janemonkey
 
BLSTK Replay n°152 - la revue luxe et digitale 25.02 au 02.03.16
BLSTK Replay n°152 - la revue luxe et digitale 25.02 au 02.03.16BLSTK Replay n°152 - la revue luxe et digitale 25.02 au 02.03.16
BLSTK Replay n°152 - la revue luxe et digitale 25.02 au 02.03.16Balistik Art
 
Fashion Brand Managment - Marchesa
Fashion Brand Managment - MarchesaFashion Brand Managment - Marchesa
Fashion Brand Managment - MarchesaShirley, Yan Yu Tin
 
[NET-A-PORTER] 9 Persuasive Principle Used by NET-A-PORTER to Boost their Con...
[NET-A-PORTER] 9 Persuasive Principle Used by NET-A-PORTER to Boost their Con...[NET-A-PORTER] 9 Persuasive Principle Used by NET-A-PORTER to Boost their Con...
[NET-A-PORTER] 9 Persuasive Principle Used by NET-A-PORTER to Boost their Con...Convertize
 
Fashion Marketing Ch 2
Fashion Marketing Ch 2Fashion Marketing Ch 2
Fashion Marketing Ch 2Msotter
 
hallu - Japanese Fashion Brand Pitch May 2015
hallu - Japanese Fashion Brand Pitch May 2015hallu - Japanese Fashion Brand Pitch May 2015
hallu - Japanese Fashion Brand Pitch May 2015Daisuke Ishii
 
Fashion marketing : Marketing statement, object,Marketing plan, Marketing str...
Fashion marketing : Marketing statement, object,Marketing plan, Marketing str...Fashion marketing : Marketing statement, object,Marketing plan, Marketing str...
Fashion marketing : Marketing statement, object,Marketing plan, Marketing str...BGMEA University of Fashion & Technology
 
NET-A-PORTER - DIGITAL MEDIA STRATEGY
NET-A-PORTER - DIGITAL MEDIA STRATEGYNET-A-PORTER - DIGITAL MEDIA STRATEGY
NET-A-PORTER - DIGITAL MEDIA STRATEGYXue Kang
 
Fashion marketing basics
Fashion marketing basicsFashion marketing basics
Fashion marketing basicsranjan trivedy
 
Versace fashion Brand Analyses presentation
Versace fashion Brand Analyses presentationVersace fashion Brand Analyses presentation
Versace fashion Brand Analyses presentationHimel Hawlader
 
Building elements and experiences at Net-A-Porter
Building elements and experiences at Net-A-PorterBuilding elements and experiences at Net-A-Porter
Building elements and experiences at Net-A-PorterRobin Glen
 
Assortment ss 2015 Stella McCartney
Assortment ss 2015 Stella McCartneyAssortment ss 2015 Stella McCartney
Assortment ss 2015 Stella McCartneyvibber
 
How to Design Compelling Content Experiences
How to Design Compelling Content ExperiencesHow to Design Compelling Content Experiences
How to Design Compelling Content ExperiencesUberflip
 

Viewers also liked (20)

Frezza_Christine_Macy’s_classification_of_costume_jewelry
Frezza_Christine_Macy’s_classification_of_costume_jewelryFrezza_Christine_Macy’s_classification_of_costume_jewelry
Frezza_Christine_Macy’s_classification_of_costume_jewelry
 
Phoenix Fashion Week 2016 Digital Program
Phoenix Fashion Week 2016 Digital ProgramPhoenix Fashion Week 2016 Digital Program
Phoenix Fashion Week 2016 Digital Program
 
Fashion Marketing Week 2
Fashion Marketing Week 2Fashion Marketing Week 2
Fashion Marketing Week 2
 
BLSTK Replay n°152 - la revue luxe et digitale 25.02 au 02.03.16
BLSTK Replay n°152 - la revue luxe et digitale 25.02 au 02.03.16BLSTK Replay n°152 - la revue luxe et digitale 25.02 au 02.03.16
BLSTK Replay n°152 - la revue luxe et digitale 25.02 au 02.03.16
 
Fashion Brand Managment - Marchesa
Fashion Brand Managment - MarchesaFashion Brand Managment - Marchesa
Fashion Brand Managment - Marchesa
 
[NET-A-PORTER] 9 Persuasive Principle Used by NET-A-PORTER to Boost their Con...
[NET-A-PORTER] 9 Persuasive Principle Used by NET-A-PORTER to Boost their Con...[NET-A-PORTER] 9 Persuasive Principle Used by NET-A-PORTER to Boost their Con...
[NET-A-PORTER] 9 Persuasive Principle Used by NET-A-PORTER to Boost their Con...
 
Fashion Marketing Ch 2
Fashion Marketing Ch 2Fashion Marketing Ch 2
Fashion Marketing Ch 2
 
hallu - Japanese Fashion Brand Pitch May 2015
hallu - Japanese Fashion Brand Pitch May 2015hallu - Japanese Fashion Brand Pitch May 2015
hallu - Japanese Fashion Brand Pitch May 2015
 
Fashion marketing : Marketing statement, object,Marketing plan, Marketing str...
Fashion marketing : Marketing statement, object,Marketing plan, Marketing str...Fashion marketing : Marketing statement, object,Marketing plan, Marketing str...
Fashion marketing : Marketing statement, object,Marketing plan, Marketing str...
 
Fashion Marketing (Branding)
Fashion Marketing (Branding)Fashion Marketing (Branding)
Fashion Marketing (Branding)
 
Vietnamese fashion brand recognition survey
Vietnamese fashion brand recognition surveyVietnamese fashion brand recognition survey
Vietnamese fashion brand recognition survey
 
NET-A-PORTER - DIGITAL MEDIA STRATEGY
NET-A-PORTER - DIGITAL MEDIA STRATEGYNET-A-PORTER - DIGITAL MEDIA STRATEGY
NET-A-PORTER - DIGITAL MEDIA STRATEGY
 
Fashion market studies_thailand_22042015
Fashion market studies_thailand_22042015Fashion market studies_thailand_22042015
Fashion market studies_thailand_22042015
 
Fashion marketing basics
Fashion marketing basicsFashion marketing basics
Fashion marketing basics
 
Versace fashion Brand Analyses presentation
Versace fashion Brand Analyses presentationVersace fashion Brand Analyses presentation
Versace fashion Brand Analyses presentation
 
Chapter 1 Fashion Marketing
Chapter   1 Fashion MarketingChapter   1 Fashion Marketing
Chapter 1 Fashion Marketing
 
Building elements and experiences at Net-A-Porter
Building elements and experiences at Net-A-PorterBuilding elements and experiences at Net-A-Porter
Building elements and experiences at Net-A-Porter
 
Assortment ss 2015 Stella McCartney
Assortment ss 2015 Stella McCartneyAssortment ss 2015 Stella McCartney
Assortment ss 2015 Stella McCartney
 
How to Design Compelling Content Experiences
How to Design Compelling Content ExperiencesHow to Design Compelling Content Experiences
How to Design Compelling Content Experiences
 
Net-a-Porter Social Media
Net-a-Porter Social MediaNet-a-Porter Social Media
Net-a-Porter Social Media
 

Similar to YAPC::EU::2011 - Mostly Lazy DBIx::Class Testing

Test::Kantan - Perl and Testing
Test::Kantan - Perl and TestingTest::Kantan - Perl and Testing
Test::Kantan - Perl and TestingTokuhiro Matsuno
 
WebNano - Ideas for Web Frameworks
WebNano - Ideas for Web FrameworksWebNano - Ideas for Web Frameworks
WebNano - Ideas for Web Frameworksguestf89f9cb
 
Modernizing Legacy Applications in PHP, por Paul Jones
Modernizing Legacy Applications in PHP, por Paul JonesModernizing Legacy Applications in PHP, por Paul Jones
Modernizing Legacy Applications in PHP, por Paul JonesiMasters
 
Ruby On Rails Overview
Ruby On Rails OverviewRuby On Rails Overview
Ruby On Rails Overviewjonkinney
 
How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)Felix Geisendörfer
 
2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD Workshop2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD WorkshopWolfram Arnold
 
Rafael Bagmanov «Scala in a wild enterprise»
Rafael Bagmanov «Scala in a wild enterprise»Rafael Bagmanov «Scala in a wild enterprise»
Rafael Bagmanov «Scala in a wild enterprise»e-Legion
 
Making friends with TDD
Making friends with TDDMaking friends with TDD
Making friends with TDDJohn Cleary
 
Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.Workhorse Computing
 
Torquebox OSCON Java 2011
Torquebox OSCON Java 2011Torquebox OSCON Java 2011
Torquebox OSCON Java 2011tobiascrawley
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyNick Sieger
 
Liquibase - Open Source version control for your database
Liquibase - Open Source version control for your databaseLiquibase - Open Source version control for your database
Liquibase - Open Source version control for your databaseBlaine Carter
 
JRuby e DSL
JRuby e DSLJRuby e DSL
JRuby e DSLjodosha
 
Ruby: Beyond the Basics
Ruby: Beyond the BasicsRuby: Beyond the Basics
Ruby: Beyond the BasicsMichael Koby
 
First adoption hackathon at BGJUG
First adoption hackathon at BGJUGFirst adoption hackathon at BGJUG
First adoption hackathon at BGJUGIvan Ivanov
 
The details of CI/CD environment for Ruby
The details of CI/CD environment for RubyThe details of CI/CD environment for Ruby
The details of CI/CD environment for RubyHiroshi SHIBATA
 

Similar to YAPC::EU::2011 - Mostly Lazy DBIx::Class Testing (20)

Test::Kantan - Perl and Testing
Test::Kantan - Perl and TestingTest::Kantan - Perl and Testing
Test::Kantan - Perl and Testing
 
WebNano - Ideas for Web Frameworks
WebNano - Ideas for Web FrameworksWebNano - Ideas for Web Frameworks
WebNano - Ideas for Web Frameworks
 
Sanity on Rails
Sanity on RailsSanity on Rails
Sanity on Rails
 
Modernizing Legacy Applications in PHP, por Paul Jones
Modernizing Legacy Applications in PHP, por Paul JonesModernizing Legacy Applications in PHP, por Paul Jones
Modernizing Legacy Applications in PHP, por Paul Jones
 
Scalax
ScalaxScalax
Scalax
 
Testing con spock
Testing con spockTesting con spock
Testing con spock
 
Ruby On Rails Overview
Ruby On Rails OverviewRuby On Rails Overview
Ruby On Rails Overview
 
How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)
 
2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD Workshop2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD Workshop
 
Intro to J Ruby
Intro to J RubyIntro to J Ruby
Intro to J Ruby
 
Rafael Bagmanov «Scala in a wild enterprise»
Rafael Bagmanov «Scala in a wild enterprise»Rafael Bagmanov «Scala in a wild enterprise»
Rafael Bagmanov «Scala in a wild enterprise»
 
Making friends with TDD
Making friends with TDDMaking friends with TDD
Making friends with TDD
 
Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.
 
Torquebox OSCON Java 2011
Torquebox OSCON Java 2011Torquebox OSCON Java 2011
Torquebox OSCON Java 2011
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 
Liquibase - Open Source version control for your database
Liquibase - Open Source version control for your databaseLiquibase - Open Source version control for your database
Liquibase - Open Source version control for your database
 
JRuby e DSL
JRuby e DSLJRuby e DSL
JRuby e DSL
 
Ruby: Beyond the Basics
Ruby: Beyond the BasicsRuby: Beyond the Basics
Ruby: Beyond the Basics
 
First adoption hackathon at BGJUG
First adoption hackathon at BGJUGFirst adoption hackathon at BGJUG
First adoption hackathon at BGJUG
 
The details of CI/CD environment for Ruby
The details of CI/CD environment for RubyThe details of CI/CD environment for Ruby
The details of CI/CD environment for Ruby
 

Recently uploaded

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 

Recently uploaded (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

YAPC::EU::2011 - Mostly Lazy DBIx::Class Testing

  • 1. Introduction Test::DBIx::Class::Schema Future Finally Mostly Lazy DBIx::Class Testing Chisel Wright Net-A-Porter 2011 Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 2. Introduction Test::DBIx::Class::Schema Future Finally In A Nutshell DBIx::Class schema sanity checking tests Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 3. Introduction Test::DBIx::Class::Schema Future Finally Why? Ongoing Quest To Be As LAZY As Possible Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 4. Introduction Test::DBIx::Class::Schema Future Finally Non-Lazy # are specific columns defined? my $thingy = $model->resultset(’BigBagOfFail’); my @columns = qw/id name department/); can_ok($thingy, @columns); Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 5. Introduction Test::DBIx::Class::Schema Future Finally Non-Lazy foreach my $column (@columns) { try { $thingy->$column(); ok("called $column()"); } catch($e) { diag $e; fail("$column() failed"); } } Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 6. Introduction Test::DBIx::Class::Schema Future Finally Non-Lazy What about . . . ? relationships custom methods Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 7. Introduction Test::DBIx::Class::Schema Future Finally Non-Lazy Decide to test something new? How many .t files do you need to edit? More than zero? Too much work!! Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 8. Introduction Test::DBIx::Class::Schema Future Finally Getting Lazy Test::DBIx::Class::Schema Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 9. Introduction Test::DBIx::Class::Schema Future Finally Test::DBIx::Class::Schema My Attempt At Laziness Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 10. Introduction Test::DBIx::Class::Schema Future Finally An example (setup) my $schematest = Test::DBIx::Class::Schema->new({ # required dsn => ’dbi:Pg:dbname=mydb’, namespace => ’MyDB::Schema’, moniker => ’SomeTable’, # optional username => ’some_user’, password => ’opensesame’, }); Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 11. Introduction Test::DBIx::Class::Schema Future Finally An example (config) # tell it what to test $schematest->methods({ columns => [ qw( id name ) ], relations => [ qw( foo ) ], custom => [ qw( some_method ) ], resultsets => [ qw( ) ], }); Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 12. Introduction Test::DBIx::Class::Schema Future Finally An example (running) $schematest->run_tests(); Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 13. Introduction Test::DBIx::Class::Schema Future Finally You get. . . can ok( @columns ) can ok( @relations ) can ok( @customs ) # row subs can ok( @resultsets ) # rs subs Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 14. Introduction Test::DBIx::Class::Schema Future Finally You also get. . . $thing->$column called ok $thing->$relation called ok test that $column exists in the database ensure related-source exists test self.* and foreign.* columns for relationships test proxied relationships PASS/FAIL for relationship validity Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 15. Introduction Test::DBIx::Class::Schema Future Finally You don’t get Functional Testing Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 16. Introduction Test::DBIx::Class::Schema Future Finally Benefits only maintaining a list (or three) lots of sanity checking find out if someone deletes columns from the database upgrading ’TDCS’ improves *.t files for free Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 17. Introduction Test::DBIx::Class::Schema Future Finally Recommendations Test one table/class per file Use Test::Aggregate Factor out ->new call for $schema Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 18. Introduction Test::DBIx::Class::Schema Future Finally In The Real World on the CPAN since 2008 used in production code since 2009 recent burst of improvements never used to test empty tables - OOPS! used to be quite basic Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 19. Introduction Test::DBIx::Class::Schema Future Finally Did It Work? YES! IMNSHO Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 20. Introduction Test::DBIx::Class::Schema Future Finally What Next? Wishlist relationship reciprocity relationships that are coderefs db columns that aren’t in the schema? tie-in with DBIx::Class::Schema::Loader Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 21. Introduction Test::DBIx::Class::Schema Future Finally End Credits QUESTIONS? Me: chisel.wright@net-a-porter.com CPANID: CHISEL github: github.com/chiselwright Module: metacpan.org/release/Test-DBIx-Class-Schema github.com/chiselwright/test-dbix-class-schema Mostly Lazy DBIx::Class Testing Net-A-Porter