X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F56-sqlite-producer.t;h=66bb8bb4c9c00a2b063f67e923358f566d7e1728;hb=2491a467cb7f1991af6aa89d09e7bfd974583242;hp=2129c298ca8c1f6586fc04a96be9d2c53401768c;hpb=03b0fa258c8580135c282b0282b5c7dcb0865c14;p=dbsrgits%2FSQL-Translator.git diff --git a/t/56-sqlite-producer.t b/t/56-sqlite-producer.t index 2129c29..66bb8bb 100644 --- a/t/56-sqlite-producer.t +++ b/t/56-sqlite-producer.t @@ -165,39 +165,31 @@ $SQL::Translator::Producer::SQLite::NO_QUOTES = 0; } { - my $table = SQL::Translator::Schema::Table->new( - name => 'foo_auto_increment', - ); - $table->add_field( - name => 'id', - data_type => 'integer', - is_nullable => 0, - is_auto_increment => 1, - ); - $table->primary_key('id'); - my $expected = [ qq]; - my $result = [SQL::Translator::Producer::SQLite::create_table($table, { no_comments => 1 })]; - is_deeply($result, $expected, 'correctly built table with autoincrement on primary key'); -} + my $table = SQL::Translator::Schema::Table->new( name => 'foobar', fields => ['foo'] ); -{ - my $table = SQL::Translator::Schema::Table->new( - name => 'foo_no_auto_increment', - ); - $table->add_field( - name => 'id', - data_type => 'integer', - is_nullable => 0, - is_auto_increment => 0, - ); - $table->primary_key('id'); - my $expected = [ qq]; - my $result = [SQL::Translator::Producer::SQLite::create_table($table, { no_comments => 1 })]; - is_deeply($result, $expected, 'correctly built table without autoincrement on primary key'); + { + my $index = $table->add_index(name => 'myindex', fields => ['foo']); + my ($def) = SQL::Translator::Producer::SQLite::create_index($index); + is($def, 'CREATE INDEX "myindex" ON "foobar" ("foo")', 'index created'); + } + + { + my $index = $table->add_index(fields => ['foo']); + my ($def) = SQL::Translator::Producer::SQLite::create_index($index); + is($def, 'CREATE INDEX "foobar_idx" ON "foobar" ("foo")', 'index created'); + } + + { + my $constr = $table->add_constraint(name => 'constr', fields => ['foo']); + my ($def) = SQL::Translator::Producer::SQLite::create_constraint($constr); + is($def, 'CREATE UNIQUE INDEX "constr" ON "foobar" ("foo")', 'constraint created'); + } + + { + my $constr = $table->add_constraint(fields => ['foo']); + my ($def) = SQL::Translator::Producer::SQLite::create_constraint($constr); + is($def, 'CREATE UNIQUE INDEX "foobar_idx02" ON "foobar" ("foo")', 'constraint created'); + } } done_testing;