mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
Simple intergration test for commit activity
This commit is contained in:
@@ -62,5 +62,62 @@ namespace Octokit.Tests.Integration.Clients
|
||||
return commit;
|
||||
}
|
||||
}
|
||||
|
||||
public class TheCommitActivityForTheLastYearStatistics
|
||||
{
|
||||
readonly IGitHubClient _client;
|
||||
readonly Repository _repository;
|
||||
readonly ICommitsClient _fixture;
|
||||
readonly string _owner;
|
||||
readonly string _repoName;
|
||||
|
||||
public TheCommitActivityForTheLastYearStatistics()
|
||||
{
|
||||
_client = new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
{
|
||||
Credentials = Helper.Credentials
|
||||
};
|
||||
|
||||
_repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
_fixture = _client.GitDatabase.Commit;
|
||||
_repository = _client.Repository.Create(new NewRepository { Name = _repoName, AutoInit = true }).Result;
|
||||
_owner = _repository.Owner.Login;
|
||||
}
|
||||
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetCommitActivityForTheLastYear()
|
||||
{
|
||||
await SeedRepository();
|
||||
var commitActivities = await _client.Statistics.GetCommitActivityForTheLastYear(_owner, _repoName);
|
||||
Assert.NotNull(commitActivities);
|
||||
}
|
||||
|
||||
async Task<Commit> SeedRepository()
|
||||
{
|
||||
var blob = new NewBlob
|
||||
{
|
||||
Content = "Hello World!",
|
||||
Encoding = EncodingType.Utf8
|
||||
};
|
||||
var blobResult = await _client.GitDatabase.Blob.Create(_owner, _repository.Name, blob);
|
||||
|
||||
var newTree = new NewTree();
|
||||
newTree.Tree.Add(new NewTreeItem
|
||||
{
|
||||
Type = TreeType.Blob,
|
||||
Mode = FileMode.File,
|
||||
Path = "README.md",
|
||||
Sha = blobResult.Sha
|
||||
});
|
||||
|
||||
var treeResult = await _client.GitDatabase.Tree.Create(_owner, _repository.Name, newTree);
|
||||
|
||||
var newCommit = new NewCommit("test-commit", treeResult.Sha);
|
||||
|
||||
var commit = await _fixture.Create(_owner, _repository.Name, newCommit);
|
||||
return commit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user