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

Option to define base URL from command line. #6

Closed
WhileLoop opened this issue Nov 17, 2017 · 6 comments
Closed

Option to define base URL from command line. #6

WhileLoop opened this issue Nov 17, 2017 · 6 comments

Comments

@WhileLoop
Copy link
Contributor

Would be nice to be able to define a base URL from the command line.

@michaelboulton
Copy link
Member

I think something planned for some future release is something similar to helm where as well as a global configuration file, you can pass in single fields with a flag like --set, eg:

# includes.ymal
variables:
    baseurl: https://example.com
    accesstoken: faketoken

Overridden with

tavern-ci --set baseurl="https://example.org" accesstoken=abc123

@benhowes
Copy link
Member

Thinking about this, it would probably have a fair bit of utility to be able to use environment variables for this purpose too, because they're well supported in most CI systems for config.

@funkyfuture
Copy link

fyi, i started to implement this here. for the time being i'm waiting for usage feedback from our developers before i add unit tests.

@benhowes
Copy link
Member

benhowes commented Feb 2, 2018

@funkyfuture do you have plans to finish the branch you were working on? I had a quick look and it's looking good so far!

@funkyfuture
Copy link

phew, so, i'm currently self-assigned to tasks far away from this. afaict my team mates are still evaluating Postman. (the main showstopper to use tavern is that they need to evaluate xml responses as well, iirc they'd also prefer yaml formulated schemas to use in conjunction with Cerberus, so a plugin system for tavern seems desirable - but that's all a very different story. [though, one thought occured to me in this context and may be noted: Docker-Compose is a good example how versioned config files - version is a top-level key - allows a tool to introduce breaking features while still working with prior config files.])

having that said, feel free to merge my progress. shall i open a pr for this?
unfortunately i can't amend tests and docs in the foreseeable future.

@michaelboulton
Copy link
Member

The 'preferred' way of doing this is to use an environment variable and then put it in either a config file or the test, eg:

# included.yaml
---
name: test includes

variables:
  base_host: "{tavern.env_vars.BASE_HOST}"
# test_request.tavern.yaml
---
test_name: run a test

stages:
  - name: run a test
    request:
      url: "{base_host}"
      # or
      url:  "{tavern.env_vars.BASE_HOST}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants