File: fix-uuid.t

package info (click to toggle)
libcatmandu-identifier-perl 0.15-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 292 kB
  • sloc: perl: 978; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 541 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env perl

use strict;
use Test::More;
use Test::Exception;

my $pkg;

BEGIN {
    $pkg = 'Catmandu::Fix::uuid';
    use_ok $pkg;
}
require_ok $pkg;

dies_ok {$pkg->new()->fix({})} "path required";

lives_ok {$pkg->new('my.field')->fix({})} "path required";

my $x = $pkg->new('my.field')->fix({});

like $x->{my}->{field}, qr/^[0-9a-f-]+$/, "generate a new uuid";

my $y = $pkg->new('my.field')->fix({my => {field => "!!!"}});

like $x->{my}->{field}, qr/^[0-9a-f-]+$/,
    "generate a new uuid in existing field";

done_testing;