mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-06 03:55:55 +00:00
Refactors a whole bunch of tests
This commit is contained in:
@@ -3,28 +3,22 @@ using System.Threading.Tasks;
|
||||
using Octokit;
|
||||
using Octokit.Tests.Integration;
|
||||
using Xunit;
|
||||
using Octokit.Tests.Integration.Helpers;
|
||||
|
||||
public class DeploymentsClientTests : IDisposable
|
||||
{
|
||||
readonly IGitHubClient _gitHubClient;
|
||||
readonly IDeploymentsClient _deploymentsClient;
|
||||
readonly Repository _repository;
|
||||
readonly Commit _commit;
|
||||
readonly string _repositoryOwner;
|
||||
private readonly IDeploymentsClient _deploymentsClient;
|
||||
private readonly RepositoryContext _context;
|
||||
private readonly Commit _commit;
|
||||
private readonly string _repositoryOwner;
|
||||
|
||||
public DeploymentsClientTests()
|
||||
{
|
||||
_gitHubClient = Helper.GetAuthenticatedClient();
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
|
||||
_deploymentsClient = _gitHubClient.Repository.Deployment;
|
||||
|
||||
var newRepository = new NewRepository(Helper.MakeNameWithTimestamp("public-repo"))
|
||||
{
|
||||
AutoInit = true
|
||||
};
|
||||
|
||||
_repository = _gitHubClient.Repository.Create(newRepository).Result;
|
||||
_repositoryOwner = _repository.Owner.Login;
|
||||
_deploymentsClient = github.Repository.Deployment;
|
||||
_context = github.CreateRepositoryContext("public-repo").Result;
|
||||
_repositoryOwner = _context.Repository.Owner.Login;
|
||||
|
||||
var blob = new NewBlob
|
||||
{
|
||||
@@ -32,7 +26,7 @@ public class DeploymentsClientTests : IDisposable
|
||||
Encoding = EncodingType.Utf8
|
||||
};
|
||||
|
||||
var blobResult = _gitHubClient.GitDatabase.Blob.Create(_repositoryOwner, _repository.Name, blob).Result;
|
||||
var blobResult = github.GitDatabase.Blob.Create(_repositoryOwner, _context.Repository.Name, blob).Result;
|
||||
|
||||
var newTree = new NewTree();
|
||||
newTree.Tree.Add(new NewTreeItem
|
||||
@@ -43,9 +37,9 @@ public class DeploymentsClientTests : IDisposable
|
||||
Sha = blobResult.Sha
|
||||
});
|
||||
|
||||
var treeResult = _gitHubClient.GitDatabase.Tree.Create(_repositoryOwner, _repository.Name, newTree).Result;
|
||||
var treeResult = github.GitDatabase.Tree.Create(_repositoryOwner, _context.Repository.Name, newTree).Result;
|
||||
var newCommit = new NewCommit("test-commit", treeResult.Sha);
|
||||
_commit = _gitHubClient.GitDatabase.Commit.Create(_repositoryOwner, _repository.Name, newCommit).Result;
|
||||
_commit = github.GitDatabase.Commit.Create(_repositoryOwner, _context.Repository.Name, newCommit).Result;
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
@@ -53,7 +47,7 @@ public class DeploymentsClientTests : IDisposable
|
||||
{
|
||||
var newDeployment = new NewDeployment { Ref = _commit.Sha, AutoMerge = false };
|
||||
|
||||
var deployment = await _deploymentsClient.Create(_repositoryOwner, _repository.Name, newDeployment);
|
||||
var deployment = await _deploymentsClient.Create(_repositoryOwner, _context.Repository.Name, newDeployment);
|
||||
|
||||
Assert.NotNull(deployment);
|
||||
}
|
||||
@@ -62,15 +56,15 @@ public class DeploymentsClientTests : IDisposable
|
||||
public async Task CanGetDeployments()
|
||||
{
|
||||
var newDeployment = new NewDeployment { Ref = _commit.Sha, AutoMerge = false };
|
||||
await _deploymentsClient.Create(_repositoryOwner, _repository.Name, newDeployment);
|
||||
|
||||
var deployments = await _deploymentsClient.GetAll(_repositoryOwner, _repository.Name);
|
||||
await _deploymentsClient.Create(_repositoryOwner, _context.Repository.Name, newDeployment);
|
||||
|
||||
var deployments = await _deploymentsClient.GetAll(_repositoryOwner, _context.Repository.Name);
|
||||
|
||||
Assert.NotEmpty(deployments);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Helper.DeleteRepo(_repository);
|
||||
_context.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user