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

DeclarativePipelineTest withEnv mock should call closure only once #199

Closed
bogdanmuresan opened this issue Apr 16, 2020 · 2 comments
Closed

Comments

@bogdanmuresan
Copy link
Contributor

Currently the closure in the withEnv mock is called multiple times (same number as env params)

                c.delegate = binding
                c.call()

should be moved outside the loop that adds the env vars, like so

        helper.registerAllowedMethod('withEnv', [List, Closure], { List list, Closure c ->
            list.each {
                //def env = helper.get
                def item = it.split('=')
                assert item.size() == 2, "withEnv list does not look right: ${list.toString()}"
                addEnvVar(item[0], item[1])
            }
            c.delegate = binding
            c.call()
        })
@stchar stchar added the bug label Apr 24, 2020
@stchar
Copy link
Contributor

stchar commented Apr 24, 2020

@bogdanmuresan
You are right. Would you like to submit a PR?

bogdanmuresan added a commit to bogdanmuresan/JenkinsPipelineUnit that referenced this issue Apr 24, 2020
@bogdanmuresan
Copy link
Contributor Author

PR opened here: #205

stchar added a commit that referenced this issue Apr 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants