Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GetSerializedCityName and CreateFullURL functions #1

Merged
merged 24 commits into from
Jun 19, 2023
Prev Previous commit
Next Next commit
Add another test
  • Loading branch information
krisukox committed Jun 19, 2023
commit 156b20482d6889e71efc726838d0d826679e2c22
22 changes: 21 additions & 1 deletion api/url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"
)

func TestCreateFullURL(t *testing.T) {
func TestCreateFullURL1(t *testing.T) {
expectedUrl := "https://www.google.com/travel/flights/search?tfs=CBwQAhooEgoyMDIzLTA3LTExagwIAhIIL20vMDg0NWJyDAgDEggvbS8wNTZfeRooEgoyMDIzLTA3LTE3agwIAxIIL20vMDU2X3lyDAgCEggvbS8wODQ1YkABSAFwAYIBCwj___________8BmAEB"

departureDate, err := time.Parse("2006-01-02", "2023-07-11")
Expand All @@ -24,3 +24,23 @@ func TestCreateFullURL(t *testing.T) {
t.Fatalf("Created url is different than expected. Created: %s Expected: %s", url, expectedUrl)
}
}

func TestCreateFullURL2(t *testing.T) {
expectedUrl := "https://www.google.com/travel/flights/search?tfs=CBwQAhooEgoyMDIzLTA4LTIwagwIAhIIL20vMDV5d2dyDAgDEggvbS8wMTU2cRooEgoyMDIzLTA5LTAxagwIAxIIL20vMDE1NnFyDAgCEggvbS8wNXl3Z0ABSAFwAYIBCwj___________8BmAEB"

departureDate, err := time.Parse("2006-01-02", "2023-08-20")
if err != nil {
t.Fatalf("Error while creating departure date")
}
returnDate, err := time.Parse("2006-01-02", "2023-09-01")
if err != nil {
t.Fatalf("Error while creating return date")
}
url, err := CreateFullURL(departureDate, returnDate, "Praga", "Berlin")
if err != nil {
t.Fatalf(err.Error())
}
if url != expectedUrl {
t.Fatalf("Created url is different than expected. Created: %s Expected: %s", url, expectedUrl)
}
}