From 04a6fd13f7ea3a45881d6e75ea1dffba38a999fd Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 8 Jul 2013 17:20:23 -0400 Subject: remove test numbers --- t/conflicts.t | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 t/conflicts.t (limited to 't/conflicts.t') diff --git a/t/conflicts.t b/t/conflicts.t new file mode 100644 index 0000000..cc9afc6 --- /dev/null +++ b/t/conflicts.t @@ -0,0 +1,104 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +use Test::More; +use Test::Fatal; +use Test::Warnings 0.005 'warning'; +use lib 't/lib/conflicts'; + +{ + use_ok('Foo::Conflicts::Good'); + is_deeply( + [ Foo::Conflicts::Good->calculate_conflicts ], + [], + "correct versions for all conflicts", + ); + is( + exception { Foo::Conflicts::Good->check_conflicts }, + undef, + "no conflict error" + ); +} + +{ + use_ok('Foo::Conflicts::Bad'); + + is_deeply( + [ Foo::Conflicts::Bad->calculate_conflicts ], + [ + { package => 'Foo', installed => '0.02', required => '0.03' }, + { package => 'Foo::Two', installed => '0.02', required => '0.02' }, + ], + "correct versions for all conflicts", + ); + is( + exception { Foo::Conflicts::Bad->check_conflicts }, + "Conflicts detected for Foo::Conflicts::Bad:\n Foo is version 0.02, but must be greater than version 0.03\n Foo::Two is version 0.02, but must be greater than version 0.02\n", + "correct conflict error" + ); +} + +{ + use_ok('Bar::Conflicts::Good'); + is_deeply( + [ Bar::Conflicts::Good->calculate_conflicts ], + [], + "correct versions for all conflicts", + ); + is( + exception { Bar::Conflicts::Good->check_conflicts }, + undef, + "no conflict error" + ); +} + +{ + use_ok('Bar::Conflicts::Bad'); + + is_deeply( + [ Bar::Conflicts::Bad->calculate_conflicts ], + [ + { package => 'Bar', installed => '0.02', required => '0.03' }, + { package => 'Bar::Two', installed => '0.02', required => '0.02' }, + ], + "correct versions for all conflicts", + ); + is( + exception { Bar::Conflicts::Bad->check_conflicts }, + "Conflicts detected for Bar::Conflicts::Bad:\n Bar is version 0.02, but must be greater than version 0.03\n Bar::Two is version 0.02, but must be greater than version 0.02\n", + "correct conflict error" + ); +} + +{ + # conflicting module is utterly broken + + use_ok('Foo::Conflicts::Broken'); + + my @conflicts; + like warning { @conflicts = Foo::Conflicts::Broken->calculate_conflicts }, + qr/Warning: Broken did not compile/, + 'Warning is issued when Broken fails to compile'; + + is_deeply( + \@conflicts, + [ + { package => 'Broken', installed => 'unknown', required => '0.03' }, + ], + "correct versions for all conflicts", + ); + + like warning { + like( + exception { Foo::Conflicts::Broken->check_conflicts }, + qr/^Conflicts detected for Foo::Conflicts::Broken:\n Broken is version unknown, but must be greater than version 0.03\n/, + "correct conflict error", + ); + }, + qr/Warning: Broken did not compile/, + 'Warning is also issued when Broken fails to compile', + ; +} + +done_testing; -- cgit v1.2.3-54-g00ecf