-
-
Notifications
You must be signed in to change notification settings - Fork 26
Abstract integration helpers #53
Copy link
Copy link
Open
Description
- I've read the guidelines for Contributing to Roots Projects
- This request isn't a duplicate of an existing request
- This is not a personal support request that should be posted on the Roots Discourse community
Summary
Abstract integration helpers. Something like:
- bin := os.Getenv("TEST_BINARY")
- if bin == "" {
- t.Error("TEST_BINARY not supplied")
- }
- if _, err := os.Stat(bin); os.IsNotExist(err) {
- t.Error(bin + "not exist")
- }
- dummy := os.Getenv("TEST_DUMMY")
- if dummy == "" {
- t.Error("TEST_DUMMY not supplied")
- }
+ bin, dummy = integrationTestHelper.prepareEnvironment()
// after the tests
+ integrationTestHelper.cleanup(dummy)integrationTestHelper.prepareEnvironment:
- Check environment variables are supplied
- Clone the dummy files into a temporary location (to be deleted by
integrationTestHelper.cleanup) - return the paths, i.e:
bin, dummy
Motivation
Cleaning up becomes problematic when not running tests with docker.
Cloning the dummy files into temporary locations ensure integration tests don't interfere with each others, so that developers don't need to clean up dummy
Cons:
- Tests take longer to run. But I think this is a reasonable trade-off
- premature abstraction is evil
Additional context
trellis-cli/cmd/dot_env_test.go
Lines 151 to 162 in 1741735
| bin := os.Getenv("TEST_BINARY") | |
| if bin == "" { | |
| t.Error("TEST_BINARY not supplied") | |
| } | |
| if _, err := os.Stat(bin); os.IsNotExist(err) { | |
| t.Error(bin + "not exist") | |
| } | |
| dummy := os.Getenv("TEST_DUMMY") | |
| if dummy == "" { | |
| t.Error("TEST_DUMMY not supplied") | |
| } |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels