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

Support passing in variables into tests #91

Merged
merged 3 commits into from
Aug 17, 2021
Merged

Conversation

seena-stripe
Copy link
Collaborator

Summary

Add option to pass in variables into executed tests.

Skycfg supports passing in variables during evaluation, but does not have a similar option to do so when evaluating tests. This works fine for tests on helper functions (where you'd have the caller pass relevant values as parameters rather than accessing the global ctx.vars directly) but meant you can't test the output of skycfg evaluation.

For example, if I wanted to assert that my proto's f_string is only 100 characters long:

def main(ctx):
    msg = MessageV3()
    msg.f_string = "hello, " + ctx.vars["name"]
    return [msg]

def test_main(ctx):
    msg = main(ctx)[0]
    ctx.assert(len(main) < 100)

Previously this would fail when running test_main because ctx.vars["name"] is not available. With this pr, it is possible to pass in the same variables when running tests.

Tests

Updated tests to skycfg_test to consider this case

internal/go/skycfg/skycfg_test.go Outdated Show resolved Hide resolved
skycfg.go Outdated Show resolved Hide resolved
@seena-stripe seena-stripe merged commit 514ceaf into trunk Aug 17, 2021
seena-stripe added a commit that referenced this pull request Aug 18, 2021
* Support passing variables into tests

* Add test for test variables

* PR Feedback
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

Successfully merging this pull request may close these issues.

2 participants