Skip to content

Commit

Permalink
unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Navid Yaghoobi <[email protected]>
  • Loading branch information
navidys committed Nov 17, 2023
1 parent d7336e4 commit 00981f4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
33 changes: 33 additions & 0 deletions flights_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ var _ = Describe("Flights", func() {

defer gock.Off()

gock.New(gopensky.OpenSkyAPIURL).
Get("/flights/invalid").
Reply(200).
BodyString("")

_, err = gopensky.GetArrivalsByAirport(conn, "KEWR", 1696755342, 1696928142)
Expect(err.Error()).To(ContainSubstring("do request: Get"))

gock.New(gopensky.OpenSkyAPIURL).
Get("/flights/arrival").
Reply(200).
Expand Down Expand Up @@ -114,6 +122,14 @@ var _ = Describe("Flights", func() {

defer gock.Off()

gock.New(gopensky.OpenSkyAPIURL).
Get("/flights/invalid").
Reply(200).
BodyString("")

_, err = gopensky.GetDeparturesByAirport(conn, "KEWR", 1696755342, 1696928142)
Expect(err.Error()).To(ContainSubstring("do request: Get"))

gock.New(gopensky.OpenSkyAPIURL).
Get("/flights/departure").
Reply(200).
Expand Down Expand Up @@ -169,6 +185,14 @@ var _ = Describe("Flights", func() {

defer gock.Off()

gock.New(gopensky.OpenSkyAPIURL).
Get("/flights/invalid").
Reply(200).
BodyString("")

_, err = gopensky.GetFlightsByInterval(conn, 1696755342, 1696928142)
Expect(err.Error()).To(ContainSubstring("do request: Get"))

gock.New(gopensky.OpenSkyAPIURL).
Get("/flights/all").
Reply(200).
Expand Down Expand Up @@ -220,6 +244,15 @@ var _ = Describe("Flights", func() {
gock.InterceptClient(gclient)

defer gock.Off()

gock.New(gopensky.OpenSkyAPIURL).
Get("/flights/invalid").
Reply(200).
BodyString("")

_, err = gopensky.GetFlightsByAircraft(conn, "c060b9", 1696755342, 1696928142)
Expect(err.Error()).To(ContainSubstring("do request: Get"))

gock.New(gopensky.OpenSkyAPIURL).
Get("/flights/aircraft").
Reply(200).
Expand Down
7 changes: 7 additions & 0 deletions states_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ var _ = Describe("States", func() {

defer gock.Off()

gock.New(gopensky.OpenSkyAPIURL).
Get("/states/invalid").
Reply(200).
BodyString("")
_, err = gopensky.GetStates(conn, 0, nil, nil, false)
Expect(err.Error()).To(ContainSubstring("do request: Get"))

gock.New(gopensky.OpenSkyAPIURL).
Get("/states/all").
Reply(200).
Expand Down
8 changes: 8 additions & 0 deletions tracks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ var _ = Describe("Tracks", func() {
_, err = gopensky.GetTrackByAircraft(conn, "c060b9", 1689193028)
Expect(err.Error()).To(ContainSubstring("unmarshalling"))

gock.New(gopensky.OpenSkyAPIURL).
Get("/tracks/invalid").
Reply(200).
BodyString("")

_, err = gopensky.GetTrackByAircraft(conn, "c060b9", 1689193028)
Expect(err.Error()).To(ContainSubstring("do request: Get"))

for _, tfile := range []string{"tracks01.json", "tracks02.json", "tracks03.json", "tracks04.json"} {
gock.New(gopensky.OpenSkyAPIURL).
Get("/tracks/all").
Expand Down

0 comments on commit 00981f4

Please sign in to comment.