lundi 19 octobre 2015

Mock a git repo for unit testing

Is there an easy way to mock a git server/repo for unit testing purposes? I don't want to test git itself, rather the ability of my code to interact with git.

I'd like to do something like

create git@localhost.com:myRepo.git c:/somepath
copy somefile.txt c:/somepath

and then when I

git clone git@localhost.com:myRepo.git

the entire contents of c:/somepath (somefile.txt) is returned, no authentication needed. I want to test how my code handles the clone, so I assume authentication isn't needed or SSH keys etc are present and valid.

I looked at git daemon but it runs on real git, so my test code ended up have to do a lot of repo content management (adding, committing, branching etc), which seems unnecessary when all I need is for git to say "yes" and return everything.

Aucun commentaire:

Enregistrer un commentaire