From: Daniel Ruoso Date: Wed, 23 Apr 2008 14:49:13 +0000 (+0000) Subject: Adding tests for Oracle->add_field X-Git-Tag: v0.11008~316 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7ad8d1b2908fb820fa7c488e566b5997a4dba246;p=dbsrgits%2FSQL-Translator.git Adding tests for Oracle->add_field --- diff --git a/t/55-oracle-add-field.t b/t/55-oracle-add-field.t new file mode 100644 index 0000000..e4e2535 --- /dev/null +++ b/t/55-oracle-add-field.t @@ -0,0 +1,50 @@ +#!/usr/bin/perl + +use FindBin qw/$Bin/; +use Test::More; +use Test::SQL::Translator; +use Test::Exception; +use Data::Dumper; +use SQL::Translator; +use SQL::Translator::Diff; + +BEGIN { + maybe_plan(2, 'SQL::Translator::Parser::YAML', + 'SQL::Translator::Producer::Oracle'); +} + +my $schema1 = $Bin.'/data/oracle/schema_diff_b.yaml'; +my $schema2 = $Bin.'/data/oracle/schema_diff_c.yaml'; + +open my $io1, '<', $schema1 or die $!; +open my $io2, '<', $schema2 or die $!; + +my ($yaml1, $yaml2); +{ + local $/ = undef; + $yaml1 = <$io1>; + $yaml2 = <$io2>; +}; + +close $io1; +close $io2; + +my $s = SQL::Translator->new(from => 'YAML'); +$s->parser->($s,$yaml1); + +my $t = SQL::Translator->new(from => 'YAML'); +$t->parser->($t,$yaml2); + +my $d = SQL::Translator::Diff->new + ({ + output_db => 'Oracle', + source_schema => $s->schema, + target_schema => $t->schema, + }); + + +my $diff = $d->compute_differences->produce_diff_sql || die $d->error; + +ok($diff, 'Diff generated.'); +like($diff, '/ALTER TABLE d_operator ADD \( foo nvarchar2\(10\) NOT NULL \)/', + 'Alter table generated.'); diff --git a/t/data/oracle/schema_diff_c.yaml b/t/data/oracle/schema_diff_c.yaml new file mode 100644 index 0000000..78f2e5f --- /dev/null +++ b/t/data/oracle/schema_diff_c.yaml @@ -0,0 +1,66 @@ +--- +schema: + procedures: {} + tables: + d_operator: + constraints: + - deferrable: 1 + expression: '' + fields: + - id_operator + match_type: '' + name: '' + on_delete: '' + on_update: '' + options: [] + reference_fields: [] + reference_table: '' + type: PRIMARY KEY + fields: + id_operator: + data_type: integer + default_value: ~ + extra: {} + is_auto_increment: 1 + is_nullable: 0 + is_primary_key: 1 + is_unique: 0 + name: id_operator + order: 58 + size: + - 0 + name: + data_type: nvarchar2(10) + default_value: ~ + extra: {} + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: name + order: 59 + size: + - 0 + foo: + data_type: nvarchar2(10) + default_value: ~ + extra: {} + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: foo + order: 59 + size: + - 0 + other: + data_type: nvarchar2(10) + default_value: ~ + extra: {} + is_nullable: 0 + is_primary_key: 0 + is_unique: 0 + name: other + order: 59 + size: + - 0 + name: d_operator + order: 11