Commit | Line | Data |
d3fad399 |
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 | random: |
19 | id: |
20 | order: 1 |
21 | name: id |
22 | type: int |
23 | size: 11 |
24 | extra: |
25 | foo: |
26 | order: 2 |
27 | name: foo |
28 | type: varchar |
29 | size: 255 |
30 | extra: |
31 | updated: |
32 | order: 3 |
33 | name: updated |
34 | type: timestamp |
35 | size: 0 |
36 | extra: |
37 | |; |
38 | |
39 | my $out; |
40 | my $tr = SQL::Translator->new( |
41 | parser => "MySQL", |
42 | producer => "YAML" |
43 | ); |
44 | |
45 | |
46 | ok($out = $tr->translate(\$create), 'Translate MySQL to YAML'); |
47 | eq_or_diff($out, $yaml, 'YAML matches expected'); |
48 | |