Update tests with airport data

This commit is contained in:
Elara 2023-08-22 18:58:54 -07:00
parent 0ff1e77ce3
commit c9846adfe5
3 changed files with 80 additions and 16 deletions

1
go.mod
View File

@ -5,6 +5,7 @@ go 1.21.0
require ( require (
github.com/alecthomas/participle/v2 v2.0.0 github.com/alecthomas/participle/v2 v2.0.0
github.com/alecthomas/repr v0.2.0 github.com/alecthomas/repr v0.2.0
github.com/go-test/deep v1.1.0
github.com/spf13/pflag v1.0.5 github.com/spf13/pflag v1.0.5
go.elara.ws/logger v0.0.0-20230421022458-e80700db2090 go.elara.ws/logger v0.0.0-20230421022458-e80700db2090
) )

2
go.sum
View File

@ -6,6 +6,8 @@ github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk
github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg=
github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/gookit/color v1.5.1 h1:Vjg2VEcdHpwq+oY63s/ksHrgJYCTo0bwWvmmYWdE9fQ= github.com/gookit/color v1.5.1 h1:Vjg2VEcdHpwq+oY63s/ksHrgJYCTo0bwWvmmYWdE9fQ=
github.com/gookit/color v1.5.1/go.mod h1:wZFzea4X8qN6vHOSP2apMb4/+w/orMznEzYsIHPaqKM= github.com/gookit/color v1.5.1/go.mod h1:wZFzea4X8qN6vHOSP2apMb4/+w/orMznEzYsIHPaqKM=
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=

View File

@ -1,11 +1,12 @@
package taf package taf
import ( import (
"reflect"
"strings" "strings"
"testing" "testing"
"time" "time"
"github.com/go-test/deep"
"go.elara.ws/taf/airports"
"go.elara.ws/taf/units" "go.elara.ws/taf/units"
) )
@ -19,6 +20,18 @@ func TestKLAX(t *testing.T) {
expected := &Forecast{ expected := &Forecast{
Identifier: "KLAX", Identifier: "KLAX",
Airport: airports.Airport{
ICAO: "KLAX",
IATA: "LAX",
Name: "Los Angeles International Airport",
City: "Los Angeles",
State: "California",
Country: "US",
Elevation: 125,
Latitude: 33.94250107,
Longitude: -118.4079971,
Timezone: "America/Los_Angeles",
},
PublishTime: time.Date(2023, time.September, 21, 20, 11, 0, 0, time.UTC), PublishTime: time.Date(2023, time.September, 21, 20, 11, 0, 0, time.UTC),
Valid: ValidPair{ Valid: ValidPair{
From: time.Date(2023, time.September, 21, 20, 0, 0, 0, time.UTC), From: time.Date(2023, time.September, 21, 20, 0, 0, 0, time.UTC),
@ -180,8 +193,8 @@ func TestKLAX(t *testing.T) {
t.Fatalf("Error during parsing: %s", err) t.Fatalf("Error during parsing: %s", err)
} }
if !reflect.DeepEqual(fc, expected) { if diff := deep.Equal(fc, expected); diff != nil {
t.Errorf("Output does not match expected") t.Error(diff)
} }
} }
@ -192,6 +205,18 @@ func TestZGSZ(t *testing.T) {
expected := &Forecast{ expected := &Forecast{
Identifier: "ZGSZ", Identifier: "ZGSZ",
Airport: airports.Airport{
ICAO: "ZGSZ",
IATA: "SZX",
Name: "Shenzhen Bao'an International Airport",
City: "Shenzhen",
State: "Guangdong",
Country: "CN",
Elevation: 13,
Latitude: 22.6392993927,
Longitude: 113.8109970093,
Timezone: "Asia/Shanghai",
},
PublishTime: time.Date(2023, time.September, 21, 19, 7, 0, 0, time.UTC), PublishTime: time.Date(2023, time.September, 21, 19, 7, 0, 0, time.UTC),
Valid: ValidPair{ Valid: ValidPair{
From: time.Date(2023, time.September, 21, 18, 0, 0, 0, time.UTC), From: time.Date(2023, time.September, 21, 18, 0, 0, 0, time.UTC),
@ -286,8 +311,8 @@ func TestZGSZ(t *testing.T) {
t.Fatalf("Error during parsing: %s", err) t.Fatalf("Error during parsing: %s", err)
} }
if !reflect.DeepEqual(fc, expected) { if diff := deep.Equal(fc, expected); diff != nil {
t.Errorf("Output does not match expected") t.Error(diff)
} }
} }
@ -300,6 +325,18 @@ func TestLFBD(t *testing.T) {
expected := &Forecast{ expected := &Forecast{
Identifier: "LFBD", Identifier: "LFBD",
Airport: airports.Airport{
ICAO: "LFBD",
IATA: "BOD",
Name: "Bordeaux-Merignac (BA 106) Airport",
City: "Bordeaux/Merignac",
State: "Nouvelle-Aquitaine",
Country: "FR",
Elevation: 162,
Latitude: 44.8283004761,
Longitude: -0.7155560255,
Timezone: "Europe/Paris",
},
PublishTime: time.Date(2023, time.September, 21, 17, 0, 0, 0, time.UTC), PublishTime: time.Date(2023, time.September, 21, 17, 0, 0, 0, time.UTC),
Valid: ValidPair{ Valid: ValidPair{
From: time.Date(2023, time.September, 21, 18, 0, 0, 0, time.UTC), From: time.Date(2023, time.September, 21, 18, 0, 0, 0, time.UTC),
@ -397,8 +434,8 @@ func TestLFBD(t *testing.T) {
t.Fatalf("Error during parsing: %s", err) t.Fatalf("Error during parsing: %s", err)
} }
if !reflect.DeepEqual(fc, expected) { if diff := deep.Equal(fc, expected); diff != nil {
t.Errorf("Output does not match expected") t.Error(diff)
} }
} }
@ -413,6 +450,18 @@ func TestUUEE(t *testing.T) {
expected := &Forecast{ expected := &Forecast{
Identifier: "UUEE", Identifier: "UUEE",
Airport: airports.Airport{
ICAO: "UUEE",
IATA: "SVO",
Name: "Sheremetyevo International Airport",
City: "Moscow",
State: "Moscow-Oblast",
Country: "RU",
Elevation: 622,
Latitude: 55.9725990295,
Longitude: 37.4146003723,
Timezone: "Europe/Moscow",
},
PublishTime: time.Date(2023, time.September, 21, 19, 58, 0, 0, time.UTC), PublishTime: time.Date(2023, time.September, 21, 19, 58, 0, 0, time.UTC),
Valid: ValidPair{ Valid: ValidPair{
From: time.Date(2023, time.September, 21, 21, 0, 0, 0, time.UTC), From: time.Date(2023, time.September, 21, 21, 0, 0, 0, time.UTC),
@ -527,8 +576,8 @@ func TestUUEE(t *testing.T) {
t.Fatalf("Error during parsing: %s", err) t.Fatalf("Error during parsing: %s", err)
} }
if !reflect.DeepEqual(fc, expected) { if diff := deep.Equal(fc, expected); diff != nil {
t.Errorf("Output does not match expected") t.Error(diff)
} }
} }
@ -541,6 +590,18 @@ func TestEGLL(t *testing.T) {
expected := &Forecast{ expected := &Forecast{
Identifier: "EGLL", Identifier: "EGLL",
Airport: airports.Airport{
ICAO: "EGLL",
IATA: "LHR",
Name: "London Heathrow Airport",
City: "London",
State: "England",
Country: "GB",
Elevation: 83,
Latitude: 51.4706001282,
Longitude: -0.4619410038,
Timezone: "Europe/London",
},
PublishTime: time.Date(2023, time.September, 21, 16, 58, 0, 0, time.UTC), PublishTime: time.Date(2023, time.September, 21, 16, 58, 0, 0, time.UTC),
Valid: ValidPair{ Valid: ValidPair{
From: time.Date(2023, time.September, 21, 18, 0, 0, 0, time.UTC), From: time.Date(2023, time.September, 21, 18, 0, 0, 0, time.UTC),
@ -620,7 +681,7 @@ func TestEGLL(t *testing.T) {
t.Fatalf("Error during parsing: %s", err) t.Fatalf("Error during parsing: %s", err)
} }
if !reflect.DeepEqual(fc, expected) { if diff := deep.Equal(fc, expected); diff != nil {
t.Errorf("Output does not match expected") t.Error(diff)
} }
} }