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

Use Hashicorp testutil for testing vs Consul API #286

Merged
merged 1 commit into from
Feb 23, 2017
Merged

Conversation

tgross
Copy link
Contributor

@tgross tgross commented Feb 22, 2017

The behaviors we're testing in the consul package are very thin wrappers around the upstream Consul API library, but that library doesn't have a interfaces (in the golang sense) that we can mock. Using httptest with a test server could give us the HTTP server but not the stateful behaviors without having to implement a lot of Consul's own behavior and we'd have to build code generation in order to validate it.

Here we'll use Hashi's own test infrastructure around Consul to run the Consul binary and tear it down after tests. This lets us run locally without Docker (and is a lot faster!) and makes it clear where the boundary of tests that depend on the server lies. In future work we can try to minimize this test region and try to eliminate the requirement or move these pieces into integration tests.

This PR contains all the commits from #285 and will be rebased once that's been merged. 8494f83 d6d0f58 contains the only commit in this PR.

@tgross tgross mentioned this pull request Feb 22, 2017
23 tasks
@tgross tgross added the v3.0.0 label Feb 22, 2017
@tgross
Copy link
Contributor Author

tgross commented Feb 23, 2017

Looks like I broke the build with some assumptions about what's in the build container. Commit incoming for that fix.

@tgross tgross force-pushed the mock_consul branch 2 times, most recently from d6d0f58 to 812a4ff Compare February 23, 2017 21:49
The behaviors we're testing in the consul package are very thin wrappers
around the upstream Consul API library, but that library doesn't have a
interfaces (in the golang sense) that we can mock. Using httptest with a
test server could give us the HTTP server but not the stateful behaviors
without having to implement a lot of Consul's own behavior and we'd have
to build code generation in order to validate it.

Here we'll use Hashi's own test infrastructure around Consul to run the
Consul binary and tear it down after tests. This lets us run locally
without Docker and makes it clear where the boundary of tests that
depend on the server lies. In future work we can try to minimize this
test region and try to eliminate the requirement or move these pieces
into integration tests.
@tgross tgross merged commit 4412c19 into master Feb 23, 2017
@tgross tgross deleted the mock_consul branch February 28, 2017 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant