コード例 #1
0
func TestVerifyAirportsBothNull(t *testing.T) {
	testData := flightsToSearch{}

	error := verifyAirports(&testData)

	utils.FailIfStringDoesntHaveSubstring(t, error, "no start airport selected !</br>")
	utils.FailIfStringDoesntHaveSubstring(t, error, "no destination airport selected !</br>")
}
コード例 #2
0
func TestVerifyStayWasZero(t *testing.T) {
	testData := buildValidTestData()
	testData.minimumStay = 0
	testData.maximumStay = 0

	error := verifyDates(&testData)

	utils.FailIfStringDoesntHaveSubstring(t, error, "minimumStay can not be 0 !</br>")
	utils.FailIfStringDoesntHaveSubstring(t, error, "maximumStay can not be 0 !</br>")
}
コード例 #3
0
func TestVerifyStayIsNegative(t *testing.T) {
	testData := buildValidTestData()
	testData.minimumStay = -1
	testData.maximumStay = -3

	error := verifyDates(&testData)

	utils.FailIfStringDoesntHaveSubstring(t, error, fmt.Sprintf("minimumStay can not be negative (%v) !</br>", testData.minimumStay))
	utils.FailIfStringDoesntHaveSubstring(t, error, fmt.Sprintf("maximumStay can not be negative (%v) !</br>", testData.maximumStay))
}
コード例 #4
0
func TestVerifyDatesAreNil(t *testing.T) {
	testData := buildValidTestData()
	testData.earliestDepartureDate = time.Time{}
	testData.latestDepartureDate = time.Time{}

	error := verifyDates(&testData)

	utils.FailIfStringDoesntHaveSubstring(t, error, "earliestDepartureDate was not set !</br>")
	utils.FailIfStringDoesntHaveSubstring(t, error, "latestDepartureDate was not set !</br>")
}
コード例 #5
0
func TestVerifyMaxStaySmallerThanMinStay(t *testing.T) {
	testData := buildValidTestData()
	testData.minimumStay = 5
	testData.maximumStay = 4

	error := verifyDates(&testData)

	utils.FailIfStringDoesntHaveSubstring(t, error, fmt.Sprintf("minimumStay was bigger (%v) than maximumStay (%v) !</br>", testData.minimumStay, testData.maximumStay))
}
コード例 #6
0
func TestVerifyDatesLatestBeforeEarliestDate(t *testing.T) {
	testData := buildValidTestData()
	testData.earliestDepartureDate = utils.RawDateNow(5)

	error := verifyDates(&testData)
	expectedMessage := fmt.Sprintf("the latestDepartureDate (%v) is temporally before the earliestDepartureDate (%v) !</br>", testData.latestDepartureDate, testData.earliestDepartureDate)

	utils.FailIfStringDoesntHaveSubstring(t, error, expectedMessage)
}
コード例 #7
0
func TestVerifyAirportsSameAirportInBoth(t *testing.T) {
	testData := flightsToSearch{}
	testData.destAirports = []string{"INN", "VIE"}
	testData.startAirports = []string{"INN", "PEK"}

	error := verifyAirports(&testData)

	utils.FailIfStringDoesntHaveSubstring(t, error, "the same airport (INN) can't be used for start and destination !</br>")
}