Add isTesting define for local testing of the api

This commit is contained in:
Christine Dodrill 2015-08-12 16:29:45 -07:00
parent fc0c98e4d2
commit 26aa6dca41
1 changed files with 7 additions and 3 deletions

View File

@ -13,6 +13,10 @@ type
episode*: int ## the episode number in the season episode*: int ## the episode number in the season
is_movie*: bool ## does this record represent a movie? is_movie*: bool ## does this record represent a movie?
when defined(isTesting):
const
API_ENDPOINT: string = "http://127.0.0.1:5000"
else:
const const
API_ENDPOINT: string = "http://ponyapi.apps.xeserv.us" API_ENDPOINT: string = "http://ponyapi.apps.xeserv.us"
@ -20,7 +24,7 @@ proc getJson(endpoint: string): json.JsonNode =
## get the HTTP body for the API base endpoint catted with the specific endpoint ## get the HTTP body for the API base endpoint catted with the specific endpoint
## requested. ## requested.
var var
data = httpclient.getContent(API_ENDPOINT & "/" & endpoint) data = httpclient.getContent(API_ENDPOINT & endpoint)
data.parseJson data.parseJson