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

Abstract integration helpers #53

Open
3 tasks done
tangrufus opened this issue Aug 15, 2019 · 1 comment
Open
3 tasks done

Abstract integration helpers #53

tangrufus opened this issue Aug 15, 2019 · 1 comment

Comments

@tangrufus
Copy link
Collaborator

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:

  1. Check environment variables are supplied
  2. Clone the dummy files into a temporary location (to be deleted by integrationTestHelper.cleanup)
  3. 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

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")
}

@swalkinshaw
Copy link
Member

Tests take longer to run. But I think this is a reasonable trade-off

If these are skipped in short mode then it doesn't matter as much?

integrationTestHelper makes sense I think once we have integration tests 👍 I'll probably have more coming with the virtualenv work

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