You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wondering if there's a reason why this repo doesn't supply a hook for running tests written with terratest (perhaps by default expecting to run go test from an expected test/ subdirectory)?
Sorta like:
- id: terratest
name: terratest
description: "Run terratest unit tests"
entry: sh -c "cd test; go test -count=1 -timeout 30m -tags=unit"
language: system
files: '\.tf$'
pass_filenames: false
Thanks!
The text was updated successfully, but these errors were encountered:
Terratest is typically used to run infrastructure tests, which can take a while—5, 10, or 30 minutes is normal, and tests that take over an hour are possible too. Also, those tests typically require authentication (e.g., authenticating too AWS) and have lots of side effects (e.g., creating resources in AWS), so if you interrupt them part way through (e.g., via CTRL+C), it leaves your environment in a messy state.
Do you really want a pre-commit hook that takes that long, has lots of environmental requirements, and can't be interrupted? Seems like that would severely discourage committing early and often...
But if we've tried to keep our "unit" tests slim, then they may not need to run 5 minutes or more on commit.
The use-case that got me to ask was for a string manipulation module, which can run real unit tests, in the sense of classic software. That takes a few seconds, most of which goes to compiling Go.
Microsoft blogged about a cute idea where they talk about limiting "unit" tests to tests which use terraform plan and parsing the output of that, vs "integration" to tests that run an apply/validate/destroy cycle. This can keep testing down to a few tens of seconds to a few minutes if modules under testing don't use a heck of a lot of remote inputs and help lint before things are in Git.
But the question is excellent, and in lieu of making it easy on devs to shoot themselves in the foot, maybe there can be a FAQ entry on this with a solution of creating a local hook as I did, and with a big fat caveat emptor against why folks might want to think twice about it.
For me this was initially annoying, as I use Go sparingly enough that navigating through installing Go, remembering how to use it (modules, packages, etc) and which tools to use took me a few hours that could have been spent just as easily on writing better tests (or better Terraform!) :)
Hey,
Wondering if there's a reason why this repo doesn't supply a hook for running tests written with terratest (perhaps by default expecting to run
go test
from an expectedtest/
subdirectory)?Sorta like:
Thanks!
The text was updated successfully, but these errors were encountered: