Skip to content

Commit

Permalink
Disable broken tests (#5073)
Browse files Browse the repository at this point in the history
* Work towards a functional travis.  Step 1: Disable broken unit tests.

* Fix functional tests

This updates the login information and model factories to work with
changes to source.

* Importer name/full name fixes.

Fix a bug where "name" was used ambigously and mapping "item name" to
"name" would confuse the importer into thinking it should also be a user
name.  Now we default to "full name" for the users name, and "item name"
for the item name.  These are still both configurable through the custom
mapping.

Also update sample csvs and remove an outdated sample.

* Max length of supplier notes is 191, not 255, as per default laravel string length.  Might make sense to change this to a text field in the future to match other places.

* Use sqlite/different db setup for unit tests.

* Fix assets api test.

* Fix Components API test.

* increase travis memory limit for functional tests.

* Use travis config for api tests as well.

* Fix memory limit file.

* Disable ApiComponentsAssetsCest until it's fixed.
  • Loading branch information
dmeltzer authored and snipe committed Feb 23, 2018
1 parent 7d49c4d commit f7dbda4
Show file tree
Hide file tree
Showing 48 changed files with 1,443 additions and 1,290 deletions.
4 changes: 2 additions & 2 deletions .env.tests
@@ -1,8 +1,8 @@
APP_ENV=testing
APP_DEBUG=true
APP_URL=http://snipe-it.localapp
DB_CONNECTION=sqlite_testing
DB_DEFAULT=sqlite_testing
DB_CONNECTION=mysql
DB_DEFAULT=mysql
DB_HOST=localhost
DB_DATABASE=snipeittests
DB_USERNAME=snipeit
Expand Down
19 changes: 19 additions & 0 deletions .env.unit-tests
@@ -0,0 +1,19 @@
APP_ENV=testing
APP_DEBUG=true
APP_URL=http://snipe-it.localapp
DB_CONNECTION=sqlite_testing
DB_DEFAULT=sqlite_testing
DB_HOST=localhost
APP_KEY=base64:tu9NRh/a6+dCXBDGvg0Gv/0TcABnFsbT4AKxrr8mwQo=


# --------------------------------------------
# OPTIONAL: LOGIN THROTTLING
# (LOGIN_LOCKOUT_DURATIONin minutes)
# --------------------------------------------
LOGIN_MAX_ATTEMPTS=1000000
LOGIN_LOCKOUT_DURATION=100000000

MAIL_DRIVER=log
MAIL_FROM_ADDR=you@example.com
MAIL_FROM_NAME=Snipe-IT
1 change: 1 addition & 0 deletions .github/travis-memory.ini
@@ -0,0 +1 @@
memory_limit= 2048M
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -18,6 +18,7 @@ php:

# execute any number of scripts before the test run, custom env's are available as variables
before_script:
- phpenv config-add .github/travis-memory.ini
- phantomjs --webdriver=4444 &
- sleep 4
- mysql -e 'CREATE DATABASE snipeit_unit;'
Expand Down Expand Up @@ -49,7 +50,7 @@ script:
# - ./vendor/bin/codecept run acceptance --env=testing-ci
- ./vendor/bin/codecept run functional --env=functional-travis
#script: ./vendor/bin/codecept run
- ./vendor/bin/codecept run api --env=testing-ci
- ./vendor/bin/codecept run api --env=functional-travis

after_success:
- codecov
Expand Down
7 changes: 4 additions & 3 deletions app/Http/Controllers/SettingsController.php
Expand Up @@ -57,9 +57,10 @@ public function getSetupIndex()

$protocol = array_key_exists('HTTPS', $_SERVER) && ( $_SERVER['HTTPS'] == "on") ? 'https://' : 'http://';

$host = $_SERVER['SERVER_NAME'];
if (($protocol === 'http://' && $_SERVER['SERVER_PORT'] != '80') || ($protocol === 'https://' && $_SERVER['SERVER_PORT'] != '443')) {
$host .= ':' . $_SERVER['SERVER_PORT'];
$host = array_key_exists('SERVER_NAME', $_SERVER) ? $_SERVER['SERVER_NAME'] : null;
$port = array_key_exists('SERVER_PORT', $_SERVER) ? $_SERVER['SERVER_PORT'] : null;
if (($protocol === 'http://' && $port != '80') || ($protocol === 'https://' && $port != '443')) {
$host .= ':' . $port;
}
$pageURL = $protocol . $host . $_SERVER['REQUEST_URI'];

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/CheckForSetup.php
Expand Up @@ -29,7 +29,7 @@ public function handle($request, Closure $next, $guard = null)

} else {
if (!($request->is('setup*')) && !($request->is('.env'))) {
return redirect(url('/').'/setup')->with('Request', $request);
return redirect(url('/').'/setup');
}

return $next($request);
Expand Down
1 change: 1 addition & 0 deletions app/Importer/Importer.php
Expand Up @@ -169,6 +169,7 @@ public function findCsvMatch(array $array, $key, $default = null)
*/
public function lookupCustomKey($key)
{
// dd($this->fieldMap);
if (array_key_exists($key, $this->fieldMap)) {
$this->log("Found a match in our custom map: {$key} is " . $this->fieldMap[$key]);
return $this->fieldMap[$key];
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Supplier.php
Expand Up @@ -23,7 +23,7 @@ class Supplier extends SnipeModel
'fax' => 'min:7|max:35|nullable',
'phone' => 'min:7|max:35|nullable',
'contact' => 'max:100|nullable',
'notes' => 'max:255|nullable',
'notes' => 'max:191|nullable', // Default string length is 191 characters..
'email' => 'email|max:150|nullable',
'zip' => 'max:10|nullable',
'url' => 'sometimes|nullable|string|max:250',
Expand Down
4 changes: 3 additions & 1 deletion database/factories/ComponentsFactory.php
Expand Up @@ -26,7 +26,9 @@
'name' => 'Crucial 4GB DDR3L-1600 SODIMM',
'category_id' => 13,
'qty' => 10,
'min_amt' => 2
'min_amt' => 2,
'location_id' => 3,
'company_id' => 2
];
});

Expand Down
3 changes: 2 additions & 1 deletion database/factories/ConsumableFactory.php
Expand Up @@ -28,7 +28,8 @@
'category_id' => 10,
'manufacturer_id' => 10,
'qty' => 10,
'min_amt' => 2
'min_amt' => 2,
'company_id' => 3
];
});

Expand Down
2 changes: 2 additions & 0 deletions database/factories/LicenseFactory.php
Expand Up @@ -29,6 +29,8 @@
'manufacturer_id' => 9,
'purchase_cost' => '299.99',
'seats' => 10,
'purchase_order' => '13503Q',
'maintained' => true
];

return $data;
Expand Down
2 changes: 1 addition & 1 deletion database/factories/ModelFactory.php
Expand Up @@ -75,7 +75,7 @@
'fax' => $faker->phoneNumber,
'email' => $faker->safeEmail,
'url' => $faker->url,
'notes' => $faker->text(255) // Supplier notes can be a max of 255 characters.
'notes' => $faker->text(191) // Supplier notes can be a max of 255 characters.
];
});

Expand Down
2 changes: 2 additions & 0 deletions phpunit.xml
Expand Up @@ -25,5 +25,7 @@
<env name="QUEUE_DRIVER" value="sync"/>

<env name="DB_CONNECTION" value="sqlite_testing" />

<server name="SERVER_NAME" value="http://testing.dev"/>
</php>
</phpunit>
526 changes: 301 additions & 225 deletions tests/_data/dump.sql

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions tests/api.suite.yml
Expand Up @@ -5,10 +5,17 @@ modules:
- REST:
url: /api/v1
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.testing
environment_file: .env.tests
disable_middleware: true
cleanup: true

0 comments on commit f7dbda4

Please sign in to comment.