NeowayLabs / neosearch

Full Text Search Library
30 stars 4 forks source link

Decouple unit tests from db/filesystem #6

Open katcipis opened 9 years ago

katcipis commented 9 years ago

Right now we have tests that are coupled with databases and the filesystem.

i4ki commented 9 years ago

I don't have an idea in a manner to solve that problem.

An index is made of N databases of reverse indices, where N is the number of document's field. Today, when we create a new index, the first step is creating a directory on filesystem to hold that databases inside... And when the instance *index.Index is created we need to create a file for store the index's metadata (info.json).

In the case of KV store implementations (leveldb, rocksdb, etc) we can mock the KVStore interface to hold data in-memory, but for the case of index creation above I don't see a good option.

Of course, we can rethink the current implementation. Do you have any idea in mind?

We have a lot of mess with the current way of doing unit tests, and I agree that we need a better way to do that.

katcipis commented 9 years ago

Actually, if we pretend to rewrite stuff the best kind of tests to write right now will be integration tests. This way we will be able to refactor with a little more safety :-). I will focus on this right now

i4ki commented 9 years ago

https://github.com/tsuru/tsuru/blob/master/fs/filesystem.go

katcipis commented 9 years ago

@tiago4orion Your idea is to define a filesystem interface and use it ? So we can mock it on the tests ? If this is the idea...I like it :-)