Skip to content

Commit

Permalink
Avoid populating db manually. (#5255)
Browse files Browse the repository at this point in the history
* Avoid populating db manually.  Instead rely on a seeded database existing and use api/fucntional tests based on that.

* Seed the Setting object with default values.

* Update Setting seeder to match web default.  Also only generate one Setting instance.
  • Loading branch information
dmeltzer authored and snipe committed Mar 29, 2018
1 parent 4c43226 commit bf2d6dd
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 1,491 deletions.
4 changes: 2 additions & 2 deletions database/factories/ModelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@
'site_name' => $faker->sentence,
'auto_increment_assets' => false,
'alert_email' => $faker->safeEmail(),
'alerts_enabled' => false,
'alerts_enabled' => true,
'brand' => 1,
'default_currency' => $faker->currencyCode,
'locale' => $faker->locale,
'pwd_secure_min' => 5,
'pwd_secure_min' => 10, // Match web setup
];
});
7 changes: 6 additions & 1 deletion database/seeds/DatabaseSeeder.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

use Illuminate\Database\Seeder;
use App\Models\Setting;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
Expand Down Expand Up @@ -33,6 +34,10 @@ public function run()
$this->call(ActionlogSeeder::class);
$this->call(CustomFieldSeeder::class);

// Only create default settings if they do not exist in the db.
if(!Setting::first()) {
factory(Setting::class)->create();
}
Artisan::call('snipeit:sync-asset-locations', ['--output' => 'all']);
$output = Artisan::output();
\Log::info($output);
Expand Down
1,472 changes: 0 additions & 1,472 deletions tests/_data/dump.sql

This file was deleted.

1 change: 0 additions & 1 deletion tests/_envs/functional-travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ modules:
dsn: 'mysql:host=localhost;dbname=snipeit_unit'
user: 'travis'
password: ''
populator: 'mysql -u travis snipeit_unit < tests/_data/dump.sql'
7 changes: 0 additions & 7 deletions tests/api.suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ modules:
depends: Laravel5
timeout: 10
- Asserts
- Db:
dsn: 'mysql:host=localhost;dbname=snipeittests'
user: 'snipeit_laravel'
password: ''
dump: tests/_data/dump.sql
populate: true
cleanup: false
config:
- Laravel5:
environment_file: .env.tests
Expand Down
8 changes: 0 additions & 8 deletions tests/functional.suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ modules:
- Laravel5:
environment_file: .env.tests
cleanup: true
- Db:
dsn: 'mysql:host=localhost;dbname=snipeittests'
user: 'snipeit_laravel'
password: ''
dump: tests/_data/dump.sql
populate: true
populator: 'mysql -u snipeit_laravel snipeittests < tests/_data/dump.sql'
cleanup: false
- REST:
depends: Laravel5
groups:
Expand Down

0 comments on commit bf2d6dd

Please sign in to comment.