MartinW
MartinW

Reputation: 5041

Can I have an in-memory git repository for unit-testing with libgit2 / ObjectiveGit?

I work on an Objective-C, Cocoa project with libgit2 and it's ObjectiveGit bindings.

In order to set up fast and clean unit tests, it would be nice to have an in-memory repository. Is this possible?

Upvotes: 2

Views: 443

Answers (1)

Carlos Martín Nieto
Carlos Martín Nieto

Reputation: 5277

You can use git_repository_new() to create the object itself without any references to on-disk resources. You can then put in your own object db, reference db, configuration and workdir path.

But writing your own databases for everything would likely be more work than abstracting away your uses of libgit2 if you don't really want to use it for the tests.

Upvotes: 2

Related Questions