Comments (7)
Regarding nr 1. - why not. It would probably make sense to put it into a custom testcl namespace ::testcl::utils. Could you provide a pull request containing:
- Well - the code
- Some tests and examples
- Some nice documentation in Readme.md
Regarding nr. 2 - could you please try rename headerName into something else - it might shadow a global variable or something @Sebastian-Brzuzek, what do you think?
BTW, we should try to use the google group for discussing before opening tickets: https://groups.google.com/forum/#!forum/testcl-user
from testcl.
I can't see any benefit with ready to use mock functions - almost the same amount of writing and no additional functionality.
I agree that verify procedures could be expanded a little bit. But I'm not sure if this is reasonable to add this to the core of TesTcl. It could be reasonable to add some optional methods to support most common verification cases, but it will be tricky to define if something is common.
We have to keep balance between amout of provided procedures, flexibility and complexity.
@Espenhh what about using this kind of test script in your case?
package require -exact testcl 1.0.2
namespace import ::testcl::*
# Comment in to enable logging
#log::lvSuppressLE info 0
proc verifyEq {what expected calculated} {
verify "$what is '$expected'" $expected eq $calculated
}
before {
event HTTP_REQUEST
}
it "should remove '/api' from URI" {
HTTP::uri "/api/users"
HTTP::header "Accept" "application/json"
on active_members pool_api return 0
verifyEq "Status code" 503 {HTTP::status}
verifyEq "Header Content-Type" "text/plain" {HTTP::header "Content-Type"}
verifyEq "Header Cache-Control" "no-cache" {HTTP::header "Cache-Control"}
verifyEq "Header X-Forwarded-SSL" "true" {HTTP::header "X-Forwarded-SSL"}
run rules/2.tcl http
}
@landro what do you think about providing some additional subpackage like ::TesTcl::verify:: for ready to use most common verification procedures (ex. verify::header or verify::statusCode)?
from testcl.
and about error...
in last argument for verify procedure you have to provide code to evaluate for condition checking.
As long as it is provided as {} (list) there is no variable substitution made by TCL interpreter. This is OK for static values. To solve this problem you have to substitute headerName variable name to pass value into verify instead of variable name. Possible solution:
proc verifyHeader {headerName expectedHeaderValue} {
verify "Header '$headerName' should be '$expectedHeaderValue'" $expectedHeaderValue eq [list HTTP::header $headerName]
}
from testcl.
@Sebastian-Brzuzek I've been thinking about this stuff today. As you said, we should try to keep testcl as tiny as possible. Less code means less code to maintain ... Before we add lots of functionality, we really need to get feedback from our user base (which I believe is quite small ... ). Makes sense?
from testcl.
@Sebastian-Brzuzek that solution solved it perfectly! Thanks :)
I agree that it's good to keep the library small at this point. Maybe the documentation could include an example using procedures to show people what's possible, I guess a lot of people who will be using this library are not very proficient in the Tcl language, so a little help in the right direction would be good :)
Feel free to close this issue if you don't want to include any helper-functions at this point.
from testcl.
@Espenhh I think it is great idea to add some more examples to documentation or even better to update existing examples with this kind of procedures to not force people read too many examples/docs.
@landro I fully agree that we should get feedback. Is there some voting mechanism which we can use to find what is "common"? I was using https://www.google.com/moderator/ for this kind of problems, but maybe there is something better. We should agree on some rules like adding only procedures which will collect some minimum number of votes?
BTW, I think we should move this discussion to our mailing list https://groups.google.com/forum/#!forum/testcl-user and close this issue until we will decide which procedures to add and how to organize this. @landro do you agree?
from testcl.
I'll close this for now, and open a discussen on the google group.
2013/10/15 Sebastian Brzuzek [email protected]
@Espenhh https://github.com/Espenhh I think it is great idea to add
some more examples to documentation or even better to update existing
examples with this kind of procedures to not force people read too many
examples/docs.@landro https://github.com/landro I fully agree that we should get
feedback. Is there some voting mechanism which we can use to find what is
"common"? I was using https://www.google.com/moderator/ for this kind of
problems, but maybe there is something better. We should agree on some
rules like adding only procedures which will collect some minimum number of
votes?BTW, I think we should move this discussion to our mailing list
https://groups.google.com/forum/#!forum/testcl-user and close this issue
until we will decide which procedures to add and how to organize this.
@landro https://github.com/landro do you agree?—
Reply to this email directly or view it on GitHubhttps://github.com//issues/23#issuecomment-26319217
.
BEKK Open
http://open.bekk.no
TesTcl - a unit test framework for iRules
http://testcl.com
from testcl.
Related Issues (20)
- Implement IP::addr
- Error using HTTP::cookie HOT 4
- Variable support HOT 5
- Unexpected unknown command invocation 'class configure' HOT 8
- Documentation should explain what you'll see if misconfigured HOT 7
- Error if test file is not found HOT 1
- Overwriting Fields in iRule HOT 5
- Docker Image HOT 3
- Update download link for jtcl-irule.jar HOT 1
- linting of the test files? HOT 1
- iRule problem HOT 1
- irules withour rule name { } HOT 4
- Return ok with failed tests HOT 2
- testing elseif/else conditions failure HOT 1
- Support for -normalized flags
- Implementing K23237429
- Support for virtual HOT 2
- Return code != 0 when tests are failing
- getfield implementation splits only on character and not string
- Variables used for calling one iRule are reused for following IT
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from testcl.