Skip to content

Commit

Permalink
Add integration test with Valiant
Browse files Browse the repository at this point in the history
  • Loading branch information
kfly8 committed Aug 18, 2024
1 parent 8d9c2bd commit 7656d21
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
cpm install -g Specio
cpm install -g MooseX::Types
cpm install -g Exporter::Tiny
cpm install -g Valiant
- run: perl Build.PL
- run: ./Build
Expand Down
34 changes: 34 additions & 0 deletions t/10-integration/Valiant.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use Test2::V0;
use Test2::Require::Module 'Valiant', '0.002004';
use Test2::Require::Module 'Type::Tiny', '2.000000';

package Local::Person {
use Moo;
use Valiant::Validations;
use Valiant::Filters;

has name => (is=>'ro');

validates name => (
length => {
maximum => 10,
minimum => 3,
}
)
}

use Types::Standard qw(InstanceOf);

subtest 'Test `kura` with Valiant' => sub {
use kura ValidLocalPerson => InstanceOf['Local::Person'] & sub { $_->valid };

isa_ok ValidLocalPerson, 'Type::Tiny';

my $person1 = Local::Person->new(name=>'foo');
my $person2 = Local::Person->new(name=>'too long naaaaaaame');

ok ValidLocalPerson->check($person1);
ok !ValidLocalPerson->check($person2);
};

done_testing;

0 comments on commit 7656d21

Please sign in to comment.