GithubHelp home page GithubHelp logo

Comments (7)

landro avatar landro commented on August 22, 2024

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:

  1. Well - the code
  2. Some tests and examples
  3. 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.

Sebastian-Brzuzek avatar Sebastian-Brzuzek commented on August 22, 2024

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.

Sebastian-Brzuzek avatar Sebastian-Brzuzek commented on August 22, 2024

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.

landro avatar landro commented on August 22, 2024

@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.

Espenhh avatar Espenhh commented on August 22, 2024

@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.

Sebastian-Brzuzek avatar Sebastian-Brzuzek commented on August 22, 2024

@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.

landro avatar landro commented on August 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.