Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent way to create and teardown test repositories #655

Closed
shiftkey opened this issue Jan 2, 2015 · 4 comments
Closed

Consistent way to create and teardown test repositories #655

shiftkey opened this issue Jan 2, 2015 · 4 comments
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone

Comments

@shiftkey
Copy link
Member

shiftkey commented Jan 2, 2015

We have a consistent way to create a test repository for the purpose of integration tests:

var repoName = Helper.MakeNameWithTimestamp("source-repo");
var repository = await client.Repository.Create(new NewRepository { Name = repoName, AutoInit = true });

And a couple of different ways to cleanup this repository:

finally
{
    if (repository != null)
       client.Repository.Delete(repository.Owner.Login, repository.Name);
}

OR

finally
{
    Helper.DeleteRepo(createdRepository);
}

OR

finally
{
    Helper.DeleteRepo("owner", "name");
}

We also have a couple of places where we use IDisposable to signal to xUnit to run some disposal code outside the scope of the test.

So basically, everything is terrible.

There's a couple of constraints to be wary of here:

  • the repository should be deleted when the test completes (or an exception occurs)
  • IDisposable.Dispose isn't await-able 😢
  • The Delete Repository API is a network call, we should probably wait for it to complete.

Ideally, I'd like some sort of wrapper which we can use:

using (var repository = gitClient.CreateTestRepository("source-repo"))
{


}

Where CreateTestRepository is an extension method that takes care of generating the unique name for the repository and calling the necessary APIs. There might be some ickyness inside Dispose to workaround the blocking/non-blocking problem, but hopefully this makes it easier to scaffold new integration tests...

@haacked
Copy link
Contributor

haacked commented Jan 4, 2015

I like the using approach. 👍

@shiftkey shiftkey mentioned this issue Apr 19, 2015
7 tasks
@heytherewill
Copy link
Contributor

What's the current status of this one? Are any bits of this closed PR relevant? May I start working on it?

@haacked
Copy link
Contributor

haacked commented Sep 22, 2015

Nobody's working on this currently. Feel free.

@devkhan
Copy link
Contributor

devkhan commented Jun 18, 2016

Should be closed?

@nickfloyd nickfloyd added Status: Up for grabs Issues that are ready to be worked on by anyone and removed up-for-grabs labels Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone
Projects
None yet
Development

No branches or pull requests

7 participants
@haacked @nickfloyd @shiftkey @ryangribble @heytherewill @devkhan and others