From feeb4946d1eb45d177092871cbe914493cc772b0 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Sun, 6 May 2018 10:21:43 -0500 Subject: [PATCH] Add some indexes and tests for airports --- .../2017_06_11_135707_create_airports_table.php | 4 ++++ tests/ImporterTest.php | 10 +++++++++- tests/data/airports.csv | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/Database/migrations/2017_06_11_135707_create_airports_table.php b/app/Database/migrations/2017_06_11_135707_create_airports_table.php index b928e2cb..04533fb1 100644 --- a/app/Database/migrations/2017_06_11_135707_create_airports_table.php +++ b/app/Database/migrations/2017_06_11_135707_create_airports_table.php @@ -22,6 +22,10 @@ class CreateAirportsTable extends Migration $table->unsignedDecimal('fuel_mogas_cost')->nullable()->default(0); $table->float('lat', 7, 4)->nullable()->default(0.0); $table->float('lon', 7, 4)->nullable()->default(0.0); + + $table->index('icao'); + $table->index('iata'); + $table->index('hub'); }); } diff --git a/tests/ImporterTest.php b/tests/ImporterTest.php index 9d67869a..92a2061d 100644 --- a/tests/ImporterTest.php +++ b/tests/ImporterTest.php @@ -569,7 +569,7 @@ class ImporterTest extends TestCase $file_path = base_path('tests/data/airports.csv'); $status = $this->importSvc->importAirports($file_path); - $this->assertCount(1, $status['success']); + $this->assertCount(2, $status['success']); $this->assertCount(1, $status['errors']); // See if it imported @@ -588,6 +588,14 @@ class ImporterTest extends TestCase $this->assertEquals(true, $airport->hub); $this->assertEquals('30.1945', $airport->lat); $this->assertEquals('-97.6699', $airport->lon); + + // See if it imported + $airport = \App\Models\Airport::where([ + 'id' => 'KSFO', + ])->first(); + + $this->assertNotNull($airport); + $this->assertEquals(true, $airport->hub); } /** diff --git a/tests/data/airports.csv b/tests/data/airports.csv index 9032b21f..0a279223 100644 --- a/tests/data/airports.csv +++ b/tests/data/airports.csv @@ -1,3 +1,4 @@ icao,iata,name,location,country,timezone,hub,lat,lon KAUS,AUS,Austin-Bergstrom,"Austin, Texas, USA", United States,America/Chicago,1,30.1945,-97.6699 -KJFK,JFK,Kennery,"Queens, New York, USA", United States,America/New_York,0,30.1945,abcd +KSFO,SFO,San Francisco,"San Francisco, California, USA", United States,America/California,"1",30.1945,-97.6699 +KJFK,JFK,Kennedy,"Queens, New York, USA", United States,America/New_York,0,30.1945,abcd