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 |
af53e4ec |
18 | schema: |
e93454af |
19 | procedures: {} |
20 | tables: |
21 | random: |
22 | comments: '' |
23 | fields: |
24 | foo: |
25 | data_type: varchar |
26 | default_value: '' |
27 | extra: {} |
28 | is_nullable: 0 |
29 | is_primary_key: 0 |
30 | is_unique: 0 |
31 | name: foo |
32 | order: 2 |
33 | size: |
34 | - 255 |
35 | id: |
36 | data_type: int |
37 | default_value: ~ |
38 | extra: {} |
39 | is_nullable: 0 |
40 | is_primary_key: 1 |
41 | is_unique: 0 |
42 | name: id |
43 | order: 1 |
44 | size: |
45 | - 11 |
46 | updated: |
47 | data_type: timestamp |
48 | default_value: ~ |
49 | extra: {} |
50 | is_nullable: 1 |
51 | is_primary_key: 0 |
52 | is_unique: 0 |
53 | name: updated |
54 | order: 3 |
55 | size: |
56 | - 0 |
57 | indices: {} |
58 | name: random |
59 | options: [] |
af53e4ec |
60 | order: 1 |
e93454af |
61 | triggers: {} |
62 | views: {} |
d3fad399 |
63 | |; |
64 | |
65 | my $out; |
66 | my $tr = SQL::Translator->new( |
67 | parser => "MySQL", |
68 | producer => "YAML" |
69 | ); |
70 | |
71 | |
72 | ok($out = $tr->translate(\$create), 'Translate MySQL to YAML'); |
73 | eq_or_diff($out, $yaml, 'YAML matches expected'); |
74 | |