-
Notifications
You must be signed in to change notification settings - Fork 9
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
mountebank v2.0 #9
Conversation
Looks like $ make errcheck
error: failed to check packages: unsupported version of go: exit status 2: flag provided but not defined: -compiled While I do think it's a useful tool, it's a bit of a shame to exclude testing earlier versions of Go just to maintain compatibility. Rather than remove the Go 1.10 checks from CI, I think it would be better to remove the |
I think having these checks in your code is a good thing, I use similar checks myself and I find them very helpful. I would not remove them and I don't think you have to sacrifice them to have Go 1.10 compatibility. The problem here is to attach those checks to particular Go versions. The results of these checks should not change depending on the Go version you are using, by running the checks for several Go versions you are not making your code better, just testing how well supported are those Go versions by the check tools. I believe these checks should only be run once, in an ad-hoc environment where an specific version of Go and the check tools are pre-installed. You can do this by building a nice docker image with a recent Go version and all testing tools installed. The unit tests on the other hand can be run on Travis for a wide range of Go versions if you want, as that can help people using old versions of Go. I think that the best way to solve this is to follow this steps:
|
@@ -1,25 +0,0 @@ | |||
# Gopkg.toml example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is great that you have get rid of the dependencies.
It would be nice if you make this repo a go module, so people can start depending on it using go mod
.
@@ -1,29 +1,25 @@ | |||
GOPACKAGES := $(shell go list github.com/senseyeio/mbgo/...) | |||
GOPACKAGES := $(shell go list ./...) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to my comment above about removing all these checks from here and making it run in a docker, I think this makefile needs some changes:
- there is no default target, so when you run
make
it runsmake errcheck
which is probably not what people wants - the integration tests should probably run whatever is required for it to work. If I run it manually without a mountebank instance running, the tests still pass, which is weird as the README explains they rely on some mountebank running.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I've added a
default
target to the Makefile which runs thefmt
,unit
andlint
targets -- see commit 6633b7c. - I've updated the Makefile to run a new shell script to handle the integration tests, which include spinning up a Docker container for mountebank, running the integration tests, then finally removing the container -- see commit 335c505.
- It's weird that the tests were passing for you even though an instance wasn't running -- I wasn't able to reproduce that locally. Maybe it was caching?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, I don't know what happened there, I cannot reproduce it either, maybe I didn't notice I had a mountebank instance running.
README.md
Outdated
@@ -19,7 +19,9 @@ $ make unit | |||
$ make integration | |||
``` | |||
|
|||
The integration test client points to a local Docker container at port 2525, with the additional ports 8080-8083 exposed for communication with test imposters. Currently tested against a mountebank v1.16.0 instance. | |||
The integration test client expects a version of mountebank running at `localhost:2525`, with the additional ports 8080-8081 exposed for test imposters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expecting users to have specific software running at specific ports is asking too much IMHO. Maybe running the integration tests in an specific environment build just for that would be a nice idea (docker maybe) to avoid people form having to setup their environment the way the lib wants.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment in the Makefile diff and/or commit 335c505.
internal/assert/assert.go
Outdated
// tests to assert deep equality between an actual and expected value. | ||
func ExpectEqual(tb testing.TB, actual, expected interface{}) { | ||
func Equals(tb testing.TB, actual, expected interface{}) { | ||
if !reflect.DeepEqual(actual, expected) { | ||
_, file, line, _ := runtime.Caller(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to use of tb.Helper instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 378d3be.
internal/assert/assert.go
Outdated
// tests to assert deep equality between an actual and expected value. | ||
func ExpectEqual(tb testing.TB, actual, expected interface{}) { | ||
func Equals(tb testing.TB, actual, expected interface{}) { | ||
if !reflect.DeepEqual(actual, expected) { | ||
_, file, line, _ := runtime.Caller(1) | ||
fmt.Printf("\033[31m%s:%d:\n\n\texp: %#v\n\n\tgot: %#v\033[39m\n\n", filepath.Base(file), line, expected, actual) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Colors don't work well across different OS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 378d3be.
…ed source code analysis tools
I re-organized the Travis CI file into separate build stages, where the source code analysis stage only uses Go 1.12, whereas the tests will run against all versions. See commit b914ea7. |
I think your last changes solve all the problems. I believe travis builds are failing due to golint not being available in the travis environment. |
Major
Minor/unrelated
localhost:2525
. This allowed me to get rid of all the Docker setup code (see f8c84d6) and remove all the dep vendoring (see 05fcbd2). As a result, you'll need to install and run a local mountebank instance yourself before running the integration tests, directly via NPM or using Docker.-or-
testutil
package into theassert
package, to make its intent more clear (see c4e84da).