Skip to content

Commit

Permalink
Adjusted test to truncate table
Browse files Browse the repository at this point in the history
  • Loading branch information
jamielsharief committed May 2, 2020
1 parent f5e4b4c commit b934c0f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/TestCase/Model/Query/BatchInsertQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ protected function setUp() : void
}
public function testInsert()
{
/**
* PostgreSQL error "duplicate key value violates unique constraint "posts_pkey" probably because of old fixture setup which bypassed
* autoincrement. Truncating table for now.
* @todo investigate this behavior
*/
$this->Post->query('TRUNCATE table posts');

$this->assertEquals(0, $this->Post->find('count'));
$records = [];
for ($i=0;$i<1000;$i++) {
$records[] = [
Expand All @@ -45,6 +53,6 @@ public function testInsert()
}

$this->assertTrue((new BatchInsertQuery($this->Post))->execute($records));
$this->assertEquals(1003, $this->Post->find('count'));
$this->assertEquals(1000, $this->Post->find('count'));
}
}

0 comments on commit b934c0f

Please sign in to comment.