Skip to content

Commit

Permalink
Support templating in root and url
Browse files Browse the repository at this point in the history
  • Loading branch information
briancurtin committed May 8, 2018
1 parent 810d56b commit 211d7cd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 10 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ it allows you to specify shorter URLs later. If you specify a default
``root: https://website.com``, you can later specify ``url: /resource``
instead of needing to specify the full ``url: https://website.com/resource``.

Both ``root`` and ``url`` support templated values which will be
formatted using environment variables. For example, if you would like
to use the ``DEPLOYMENT`` environment variable to fill your ``root``,
``root: https://{DEPLOYMENT}.website.com/api`` will allow you to do this.

warmup
++++++

Expand Down Expand Up @@ -179,6 +184,11 @@ specified in the ``default`` section, this must be a fully formed URL. If
you do have a ``root`` specified, this can be a fragment of the URL that will
be joined with that ``root`` as the above example does.

As with ``root``, ``url`` supports templated values which will be formatted
using environment variables. For example, if you would like
to use the ``VERSION`` environment variable to fill your ``url``,
``url: /api/{VERSION}/status`` will allow you to do this.

method
++++++

Expand Down
5 changes: 3 additions & 2 deletions source/_pine.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,10 @@ def get_tests(defaults, config, test_names):
continue

# If there's a configured root url, join it up, otherwise
# we'll assume the url is fully formed.
# we'll assume the url is fully formed. Format it as well.
if defaults.root:
values["url"] = urljoin(defaults.root, values["url"])
value = urljoin(defaults.root, values["url"])
values["url"] = value.format(**os.environ)

test = dict(defaults.__dict__)
test["name"] = test_name
Expand Down

0 comments on commit 211d7cd

Please sign in to comment.