Up until now we’ve gotten away with returning just the current UTC time.
Lets extend our solution to accept a timezone
from the user and return the current time in that timezone.
This one is all on you! What is the first test that you’d like to write?
/api/time/
endpoint should accept a timezone
query parameter that provides a timezone in the IANA “Australia/Melbourne” formattimezone
, offset
and current_time
fields
timezone
field should include the name of the timezoneoffset
field should include the current offset for the timezone in ±hhmm
formatcurrent_time
field should include the current time in the specified timezone
error
key should be provided in the JSONWhat tests did you write? Here’s how I got started (spoilers!)
My test concentrate on the happy path and don’t test many edge cases. Take a moment to think about other things that you could have tested.