|| at Dec 20, 2012 at 6:52 pm
Thanks, I think the shell script makes the most sense, so I can start Redis
once and test several packages against it. It would be nice if I could
write that sort of code in Go so as not to depend on a shell, but I don't
have any requirements that make a shell dependency a problem.
If I run "go test pkg1 pkg2 pkg3", does it compile and execute a separate
binary for each package? If so, I suppose an external startup would be the
only way to make separate packages share a single Redis process, anyway.
On Thu, Dec 20, 2012 at 11:32 AM, Kyle Lemons wrote:
You could write a table-driven test and start it at the beginning of the
test and defer the shutdown. No, there is no standard "on exit" behavior
in go test. You could also write a shell script that starts it up, runs go
test, and then stops it.
On Thu, Dec 20, 2012 at 1:27 PM, Patrick Higgins <firstname.lastname@example.org
I am writing some tests using the "go test" utility which access Redis,
making them not strict unit tests. I am doing this because there isn't much
Go code to test: there are Lua functions defined in my Go code which
execute in Redis, and it's the Lua code I really wish to test, so
communication with Redis is required.
Right now I plan to start Redis externally before running the tests, but
it got me thinking if it would even be possible to start it when the test
starts (in a package initializer, perhaps) and shutdown it down when the
tests complete. I haven't found any sort of hooks to enable the
stop-on-shutdown behavior. Did I overlook something?
Are there any other suggestions for ways to write such tests?