microsoft / go-mssqldb

Microsoft SQL server driver written in go language
BSD 3-Clause "New" or "Revised" License
286 stars 65 forks source link

Use dockertest to instantiate the test database #164

Open ngehrsitz opened 11 months ago

ngehrsitz commented 11 months ago

This project would benefit from using dockertest to dynamically launch the database instance required for the tests.

shueybubbles commented 11 months ago

It looks promising. It would be fine for some tests but the setup needed for many scenarios is more complex. We have to test SSPI auth, Always Encrypted, named pipes, etc. Today we rely on docker to test against SQL server on Linux in the github actions, and we rely on Appveyor to cover Windows SQL instances. Presumably the helper function that returns the connection could switch over to dockertest if there's no .connstr file and no environment variable set. It would reduce the work needed for a new contributor to get tests running locally.

ngehrsitz commented 11 months ago

Dockertest is not limited to just using func TestMain(m *testing.M) for the setup. You can just as well use it with a custom setupMyScenario() that is different for every test. Github Actions will also just work by default as long as you have docker available in them. The only place I see the need for a .connstr as fallback would be the Windows test environments.