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

Additional errors #106

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const fastify = require('fastify')

const last_updated_fresh = Math.floor(Date.now() / 1000) - 30
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general rule of thumb, testing based on an actual clock could lead to unexpected results and false negatives / positives. Using a mocked clock is preferable.


function build(opts = {}) {
const app = fastify(opts)

Expand Down Expand Up @@ -49,7 +51,7 @@ function build(opts = {}) {

app.get('/free_bike_status.json', async function(request, reply) {
return {
last_updated: 1566224400,
last_updated: last_updated_fresh,
ttl: 0,
version: '2.2',
data: {
Expand Down
14 changes: 5 additions & 9 deletions gbfs-validator/__test__/fixtures/conditionnal_vehicle_type_id.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const fastify = require('fastify')

const last_updated_fresh = Math.floor(Date.now() / 1000) - 30

function build(opts = {}) {
const app = fastify(opts)

Expand Down Expand Up @@ -64,15 +66,12 @@ function build(opts = {}) {
propulsion_type: 'human',
name: 'Example Basic Bike',
default_reserve_time: 30,
return_type: ['any_station', 'free_floating'],
vehicle_assets: {
icon_url: 'https://www.example.com/assets/icon_bicycle.svg',
icon_url_dark:
'https://www.example.com/assets/icon_bicycle_dark.svg',
icon_last_modified: '2021-06-15'
},
default_pricing_plan_id: 'bike_plan_1',
pricing_plan_ids: ['bike_plan_1', 'bike_plan_2', 'bike_plan_3']
}
},
{
vehicle_type_id: 'efg456',
Expand All @@ -81,14 +80,11 @@ function build(opts = {}) {
name: 'Example Electric Car',
default_reserve_time: 30,
max_range_meters: 100,
return_type: ['any_station', 'free_floating'],
vehicle_assets: {
icon_url: 'https://www.example.com/assets/icon_car.svg',
icon_url_dark: 'https://www.example.com/assets/icon_car_dark.svg',
icon_last_modified: '2021-06-15'
},
default_pricing_plan_id: 'car_plan_1',
pricing_plan_ids: ['car_plan_1', 'car_plan_2', 'car_plan_3']
}
}
]
}
Expand All @@ -97,7 +93,7 @@ function build(opts = {}) {

app.get('/free_bike_status.json', async function(request, reply) {
return {
last_updated: 1566224400,
last_updated: last_updated_fresh,
ttl: 0,
version: '2.2',
data: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const fastify = require('fastify')

const last_updated_fresh = Math.floor(Date.now() / 1000) - 30

function build(opts = {}) {
const app = fastify(opts)

Expand Down Expand Up @@ -60,7 +62,6 @@ function build(opts = {}) {
propulsion_type: 'human',
name: 'Example Basic Bike',
default_reserve_time: 30,
return_type: ['any_station', 'free_floating'],
vehicle_assets: {
icon_url: 'https://www.example.com/assets/icon_bicycle.svg',
icon_url_dark:
Expand All @@ -77,7 +78,6 @@ function build(opts = {}) {
name: 'Example Electric Car',
default_reserve_time: 30,
max_range_meters: 100,
return_type: ['any_station', 'free_floating'],
vehicle_assets: {
icon_url: 'https://www.example.com/assets/icon_car.svg',
icon_url_dark: 'https://www.example.com/assets/icon_car_dark.svg',
Expand All @@ -93,7 +93,7 @@ function build(opts = {}) {

app.get('/station_status.json', async function(request, reply) {
return {
last_updated: 1566224400,
last_updated: last_updated_fresh,
ttl: 0,
version: '2.2',
data: {
Expand Down
4 changes: 3 additions & 1 deletion gbfs-validator/__test__/fixtures/missing_vehicle_types.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const fastify = require('fastify')

const last_updated_fresh = Math.floor(Date.now() / 1000) - 30

function build(opts = {}) {
const app = fastify(opts)

Expand Down Expand Up @@ -49,7 +51,7 @@ function build(opts = {}) {

app.get('/free_bike_status.json', async function(request, reply) {
return {
last_updated: 1566224400,
last_updated: last_updated_fresh,
ttl: 0,
version: '2.2',
data: {
Expand Down
10 changes: 6 additions & 4 deletions gbfs-validator/__test__/fixtures/plan_id.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const fastify = require('fastify')

const last_updated_fresh = Math.floor(Date.now() / 1000) - 30

function build(opts = {}) {
const app = fastify(opts)

app.get('/gbfs.json', async function(request, reply) {
app.get('/gbfs.json', async function (request, reply) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nit-picky, but why add a whitespace here?

return {
last_updated: 1566224400,
ttl: 0,
Expand Down Expand Up @@ -57,7 +59,7 @@ function build(opts = {}) {

app.get('/free_bike_status.json', async function(request, reply) {
return {
last_updated: 1566224400,
last_updated: last_updated_fresh,
ttl: 0,
version: '2.3',
data: {
Expand Down Expand Up @@ -109,7 +111,7 @@ function build(opts = {}) {
propulsion_type: 'human',
name: 'Example Basic Bike',
default_reserve_time: 30,
return_type: ['any_station', 'free_floating'],
return_constraint: 'any_station',
vehicle_assets: {
icon_url: 'https://www.example.com/assets/icon_bicycle.svg',
icon_url_dark:
Expand All @@ -126,7 +128,7 @@ function build(opts = {}) {
name: 'Example Electric Car',
default_reserve_time: 30,
max_range_meters: 100,
return_type: ['any_station', 'free_floating'],
return_constraint: 'free_floating',
vehicle_assets: {
icon_url: 'https://www.example.com/assets/icon_car.svg',
icon_url_dark: 'https://www.example.com/assets/icon_car_dark.svg',
Expand Down
12 changes: 4 additions & 8 deletions gbfs-validator/__test__/fixtures/v3.0-RC/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,13 @@ class MockRequests {
}
],
default_reserve_time: 30,
return_type: ['any_station', 'free_floating'],
return_constraint: 'hybrid',
vehicle_assets: {
icon_url: 'https://www.example.com/assets/icon_bicycle.svg',
icon_url_dark:
'https://www.example.com/assets/icon_bicycle_dark.svg',
icon_last_modified: '2021-06-15'
},
default_pricing_plan_id: 'bike_plan_1',
pricing_plan_ids: ['bike_plan_1', 'bike_plan_2', 'bike_plan_3']
}
},
{
vehicle_type_id: 'cartype1',
Expand All @@ -138,14 +136,12 @@ class MockRequests {
],
default_reserve_time: 30,
max_range_meters: 100,
return_type: ['any_station', 'free_floating'],
return_constraint: 'any_station',
vehicle_assets: {
icon_url: 'https://www.example.com/assets/icon_car.svg',
icon_url_dark: 'https://www.example.com/assets/icon_car_dark.svg',
icon_last_modified: '2021-06-15'
},
default_pricing_plan_id: 'car_plan_1',
pricing_plan_ids: ['car_plan_1', 'car_plan_2', 'car_plan_3']
}
}
]
}
Expand Down
26 changes: 18 additions & 8 deletions gbfs-validator/__test__/fixtures/v3.0-RC/exaustive.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class MockRequests {
}
],
default_reserve_time: 30,
return_type: ['any_station', 'free_floating'],
return_constraint: 'free_floating',
vehicle_assets: {
icon_url: 'https://www.example.com/assets/icon_bicycle.svg',
icon_url_dark:
Expand Down Expand Up @@ -243,7 +243,6 @@ class MockRequests {
vehicle_accessories: ['automatic', 'air_conditioning'],
g_CO2_km: 0,
default_reserve_time: 30,
return_type: ['any_station', 'free_floating'],
vehicle_image: 'https://www.example.com/assets/car.jpg',
make: [
{
Expand All @@ -267,7 +266,6 @@ class MockRequests {
wheel_count: 4,
max_permitted_speed: 200,
rated_power: 100,
default_reserve_time: 30,
return_constraint: 'hybrid',
vehicle_assets: {
icon_url: 'https://www.example.com/assets/icon_car.svg',
Expand All @@ -290,7 +288,20 @@ class MockRequests {
data: {
stations: [
{
station_id: 'pga',
station_id: 'station1',
name: [
{
text: 'Station 1',
language: 'en'
}
],
lat: 12.345578,
lon: 45.678801,
is_virtual_station: false,
capacity: 5
},
{
station_id: 'station2',
name: [
{
text: 'Parking garage A',
Expand Down Expand Up @@ -329,7 +340,7 @@ class MockRequests {
parking_type: 'underground_parking',
parking_hoop: false,
contact_phone: '+33109874321',
capacity: 10,
capacity: 20,
vehicle_type_area_capacity: [
{
vehicle_type_id: 'abc123',
Expand Down Expand Up @@ -454,8 +465,7 @@ class MockRequests {
rental_uris: {
android:
'https://www.example.com/app?vehicle_id=973a5c94-c288-4a2b-afa6-de8aeb6ae2e5&platform=android&',
ios:
'https://www.example.com/app?vehicle_id=973a5c94-c288-4a2b-afa6-de8aeb6ae2e5&platform=ios',
ios: 'https://www.example.com/app?vehicle_id=973a5c94-c288-4a2b-afa6-de8aeb6ae2e5&platform=ios',
web: 'https://www.example.com/app?sid=1234567890'
},
vehicle_type_id: 'biketype1',
Expand Down Expand Up @@ -584,7 +594,7 @@ class MockRequests {
language: 'en'
}
],
currency: 'CAD',
currency: 'EUR',
price: 3.0,
reservation_price_flat_rate: 3.0,
is_taxable: true,
Expand Down
Loading
Loading