Add some indexes and tests for airports

This commit is contained in:
Nabeel Shahzad
2018-05-06 10:21:43 -05:00
parent f671d3f624
commit feeb4946d1
3 changed files with 15 additions and 2 deletions

View File

@@ -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');
});
}

View File

@@ -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);
}
/**

View File

@@ -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
1 icao iata name location country timezone hub lat lon
2 KAUS AUS Austin-Bergstrom Austin, Texas, USA United States America/Chicago 1 30.1945 -97.6699
3 KJFK KSFO JFK SFO Kennery San Francisco Queens, New York, USA San Francisco, California, USA United States America/New_York America/California 0 1 30.1945 abcd -97.6699
4 KJFK JFK Kennedy Queens, New York, USA United States America/New_York 0 30.1945 abcd