A better YAML producer, actually using the YAML module. Updated test
[dbsrgits/SQL-Translator.git] / t / 24yaml.t
1 #!/usr/local/bin/perl
2 # vim: set ft=perl:
3
4 use strict;
5 use Test::More tests => 2;
6 use Test::Differences;
7 use SQL::Translator;
8
9 my $create = q|
10 CREATE TABLE random (
11     id int auto_increment PRIMARY KEY,
12     foo varchar(255) not null default '',
13     updated timestamp
14 );
15 |;
16
17 my $yaml = q|--- #YAML:1.0
18 schema:
19   random:
20     foo:
21       extra: {}
22       name: foo
23       order: 2
24       size:
25         - 255
26       type: varchar
27     id:
28       extra: {}
29       name: id
30       order: 1
31       size:
32         - 11
33       type: int
34     updated:
35       extra: {}
36       name: updated
37       order: 3
38       size:
39         - 0
40       type: timestamp
41 |;
42
43 my $out;
44 my $tr = SQL::Translator->new(
45     parser   => "MySQL",
46     producer => "YAML"
47 );
48
49
50 ok($out = $tr->translate(\$create), 'Translate MySQL to YAML');
51 eq_or_diff($out, $yaml, 'YAML matches expected');
52