alexbrainman / odbc

odbc driver written in go
BSD 3-Clause "New" or "Revised" License
352 stars 140 forks source link

Tests for MSAccess #84

Open flibustenet opened 7 years ago

flibustenet commented 7 years ago

I began to write tests for MSAccess database. Is it interesting to include them in the project ? Do you have some points I must take care ? I need to include an empty database (128kb), is it ok ? Then at each running test the database will change, so I think it's better to make a copy of the empty database for the test. But I don't know how to remove the file at the end because the database is kept open (by the pool ?). Should I add a .gitignore of test.mdb ?

Thanks for advices...

alexbrainman commented 7 years ago

Is it interesting to include them in the project ?

If you think they will be helpful to others, I am fine with that.

Do you have some points I must take care ?

I do not have anything right now.

I need to include an empty database (128kb), is it ok ?

I am concerned about the size. We have to consider others, who are not interested in MSAccess. Perhaps it is possible to create database on the fly? Perhaps you could include some code (maybe use "go generate") to download whatever you need before testing.

Then at each running test the database will change, so I think it's better to make a copy of the empty database for the test.

Sounds like a plan. Maybe copy it into %TMP% directory.

But I don't know how to remove the file at the end because the database is kept open (by the pool ?).

We would have to find a way to make MSAccess close database file, so we can delete it after test. We have access to all package internals, so we can do whatever is required. We just need to know what is required for MSAccess.

Should I add a .gitignore of test.mdb ?

There are already some FoxPro files in testdata directory. But lets wait until we decide how test.mdb will appear on user's computer first.

Alex

flibustenet commented 7 years ago

I can delete the test database, I forgot a row.Close() It could be better to create the database on the fly, also because it will use the database format (MSAccess version) of the tester. I can do it with https://github.com/go-ole/go-ole/oleutil but I continue to search for an other solution.

alexbrainman commented 7 years ago

I continue to search for an other solution

Can you run an external command to create database? You might need MSAccess installed for that, but that is, probably, ok.

Alex

flibustenet commented 7 years ago

I don't know a command line to create a database. But the good news is that a gziped empty database is only 2K.

alexbrainman commented 7 years ago

a gziped empty database is only 2K.

2k sounds good. Stick it in testdata directory.

Alex