Setup EventStore for integration tests

Hi

Is there a way to setup a running instance of the EventStore for integration tests. I would like to call a function like this for a single stream:

public static void Reset() {

using (var connection = EventStoreConnection.Create(gesAddress)) {

connection.Connect();

var metadata = connection.GetStreamMetadata(“configuration”);

if (!metadata.IsStreamDeleted)

connection.DeleteStream(“configuration”, ExpectedVersion.Any);

}

}

However once I called this the stream “configuration” is deleted and when I try to append to the stream I get a StreamDeletedException. I read somewhere that you can scavenge the database to remove all deleted streams but I cannot find a way to do it via the ClientApi?

Is there a way to delete an entire database using the ClientApi?

Regards

Stefan Olofsson

Why not recreate a new store or NOT reuse the same identifiers?

What do you mean with recreate a new store - Shut down EventStore, purge the database files and restart?
How do I do that easy from within MSTest methods (which Im stuck with)?

In our system there is ONE configuration that can be viewed as a stream of events. Knowing what that stream is named and to be able to subscribe to it at system startup/initializing seems to be a simple and easy approach. For all other enteties in our system this isn’t an issue and I can name the streams with Guids or whatever.

There are three distinct solutions to this problem.

The first is new and in dev. It is known as “Truncate Before” it allows for the soft delete of a stream (but the event numbers will not reset back to 0).

The second is ability to run ES in memory only. This will be released shortly.

The last as yves mentions is to use a different stream each time. This can be done even with named streams by doing something like name + Guid during tests

The first and second will be on master very soon.

Cheers,

Greg

Thanks for the replies

Using different streams each test did the trick for now. Looking forward to the in memory option. Any eta of when it will be released?

/Stefan

I think it will be in next 4-6 weeks

Will this also include being able to run in embedded mode? I know you’re working on Event Store Lair that could probably be used from shared hosting, but until then.

In memory only mode is currently on dev for both embedded and console runner.

Cheers,

Greg

To be clear when I said “on dev” I meant the dev branch. Binaries will be released this week but you can use it now of you want

Actually I wanted to know if there is an embedded runner which you’ve now answered me. Thanks!

You mean so you can self host? You can easily self host a node (we do it internally in our tests see “mini node”

Cheers,

Greg

Yes that’s what I meant. I’ll have a look at “mini node”.