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

bug - modify_state hook should operate on a copy of state #27

Merged
merged 4 commits into from
Sep 18, 2020

Conversation

marcoceppi
Copy link
Contributor

@marcoceppi marcoceppi commented Sep 10, 2020

Two things are addressed in this. The first is what is passed back to the function under test. During replays that's TerraformTestApi and during live runs it's TerraformState while functionally both the same thing, we want to make sure we don't leak TerraformState directly to the function under test as TerraformTestApi interface will likely grow in the future.

Second item, if the modify_state hook is implemented in a test run then the modified state is not only written to disk but also returned to the function under test. What should happen is the unmodified state during record / live runs is returned to the function under test and a copy is passed through the modify_state hook before writing to disk.

@codecov
Copy link

codecov bot commented Sep 10, 2020

Codecov Report

Merging #27 into master will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #27      +/-   ##
==========================================
+ Coverage   92.59%   92.64%   +0.04%     
==========================================
  Files           8        8              
  Lines         459      462       +3     
==========================================
+ Hits          425      428       +3     
  Misses         34       34              
Impacted Files Coverage Δ
pytest_terraform/tf.py 96.29% <100.00%> (+0.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a78ff84...8d33e5c. Read the comment docs.

@marcoceppi marcoceppi force-pushed the hook/before-save branch 4 times, most recently from 4f2b1a3 to 9caba07 Compare September 11, 2020 15:52
@marcoceppi marcoceppi changed the title feature - Add hook for modifying state only before it's saved to disk bug - modify_state hook should operate on a copy of state Sep 11, 2020
pytest_terraform/tf.py Outdated Show resolved Hide resolved
pytest_terraform/tf.py Outdated Show resolved Hide resolved
pytest_terraform/tf.py Outdated Show resolved Hide resolved
Copy link
Contributor

@kapilt kapilt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks

@marcoceppi marcoceppi merged commit b4ddce6 into master Sep 18, 2020
@marcoceppi marcoceppi deleted the hook/before-save branch September 18, 2020 18:23
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