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

Unified configuration syntax #13

Closed
ptrthomas opened this issue Feb 24, 2017 · 1 comment
Closed

Unified configuration syntax #13

ptrthomas opened this issue Feb 24, 2017 · 1 comment
Assignees

Comments

@ptrthomas
Copy link
Member

ptrthomas commented Feb 24, 2017

There was a rush to introduce ssl support and we ended up with the syntax ssl enabled

Come to think of it there may be a few more similar needs in the future. An immediate need that comes to mind is setting a default time-out duration.

Would be great to get feedback on the following proposals. I'd like to "unify" the means to set config within the existing keywords as far as possible. One principle is to not bloat the syntax.

  1. using set, and Karate will introduce a config special variable. Downside is that the name config could tend to be used as a variable name by users. Also, extra code needs to be added to "detect" a property change
* set config.ssl.enabled = true
  1. use a built in function and pass json, quite generic. hmm, there's no way to just execute a block of JS code other than assert, interesting. I think I'll keep it that way and restrict the extensibility entry-point of Karate to the call keyword
* assert configure({ sslEnabled: true })
# if we decide to introduce an 'execute' keyword, but 'side-effects' are bad :P
* execute configure({ sslEnabled: true }}
# maybe one keyword for all 'configure' needs would be a good solution
* configure { sslEnabled: true }
# one nice thing is possibly multiple config in one operation
* configure { sslEnabled: true, timeOut: 60 }
  1. use call and a built in configure function
* call configure { sslEnabled: true, timeOut: 60 }
@ptrthomas
Copy link
Member Author

ptrthomas commented Feb 24, 2017

One more idea. The way headers works today is not aligned with the rest of Karate, it is a "magic variable" and a user is expected to modify this at the start of a script. There is a significant risk that users would use the name headers for other variables.

I propose to unify this into configuration as well, and it seems to make sense. Now, since the "headersFunction" is a non-primitive, that too a JS function, forcing it into a JSON envelope does not sound right. So how about this, and assume we have one configure keyword.

* configure ssl = true
* configure headers = read('my-headers.js')
* configure timeout = 60

I like this already.

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

1 participant