File: schema.t

package info (click to toggle)
libcatmandu-exporter-table-perl 0.3.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 124 kB
  • sloc: perl: 71; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 611 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
use strict;
use warnings;
use Test::More;
use Catmandu::Exporter::Table;


sub is_table(@) {
    my ($message,$expect,$data) = (pop,pop,shift);
    my $out = "";
    my $exporter = Catmandu::Exporter::Table->new(@_, file => \$out);
    $exporter->add($_) for @$data;
    $exporter->commit;
    is $out, $expect, $message;
}

foreach my $schema (
    { fields => [ { name => "c", title => "C" }, { name => "b" } ] },
    't/schema.json'
) {
    is_table [{a => 1, b => 2, c => 3}], schema => $schema
, <<TABLE, 'set fields and columns via JSON Table schema';
| C | b |
|---|---|
| 3 | 2 |
TABLE
}

done_testing;