mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-07 04:16:51 +00:00
added Blob to IGitDatabaseClient, added integration tests
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Net.Http.Headers;
|
||||
using Octokit;
|
||||
using Octokit.Tests.Integration;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using System.Text;
|
||||
|
||||
public class BlobClientTests : IDisposable
|
||||
{
|
||||
readonly IBlobsClient _fixture;
|
||||
readonly Repository _repository;
|
||||
readonly string _owner;
|
||||
|
||||
public BlobClientTests()
|
||||
{
|
||||
var client = new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
{
|
||||
Credentials = Helper.Credentials
|
||||
};
|
||||
_fixture = client.GitDatabase.Blob;
|
||||
|
||||
var repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
_repository = client.Repository.Create(new NewRepository { Name = repoName, AutoInit = true }).Result;
|
||||
_owner = _repository.Owner.Login;
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateABlob()
|
||||
{
|
||||
var blob = new NewBlob
|
||||
{
|
||||
Content = "Hello World!",
|
||||
Encoding = EncodingType.Utf8
|
||||
};
|
||||
|
||||
var result = await _fixture.Create(_owner, _repository.Name, blob);
|
||||
|
||||
Assert.False(String.IsNullOrWhiteSpace(result.Sha));
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetABlob()
|
||||
{
|
||||
var newBlob = new NewBlob
|
||||
{
|
||||
Content = "Hello World!",
|
||||
Encoding = EncodingType.Utf8
|
||||
};
|
||||
|
||||
var result = await _fixture.Create(_owner, _repository.Name, newBlob);
|
||||
var blob = await _fixture.Get(_owner, _repository.Name, result.Sha);
|
||||
|
||||
Assert.Equal(result.Sha, blob.Sha);
|
||||
Assert.Equal(EncodingType.Base64, blob.Encoding);
|
||||
|
||||
var contents = Encoding.UTF8.GetString(Convert.FromBase64String(blob.Content));
|
||||
|
||||
Assert.Equal("Hello World!", contents);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Helper.DeleteRepo(_repository);
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Clients\AssigneesClientTests.cs" />
|
||||
<Compile Include="Clients\BlobClientTests.cs" />
|
||||
<Compile Include="Clients\CommitsClientTests.cs" />
|
||||
<Compile Include="Clients\CommitStatusClientTests.cs" />
|
||||
<Compile Include="Clients\GistsClientTests.cs" />
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
public GitDatabaseClient(IApiConnection apiConnection)
|
||||
: base(apiConnection)
|
||||
{
|
||||
Blob = new BlobsClient(apiConnection);
|
||||
Tag = new TagsClient(apiConnection);
|
||||
Commit = new CommitsClient(apiConnection);
|
||||
Reference = new ReferencesClient(apiConnection);
|
||||
}
|
||||
|
||||
public IBlobsClient Blob { get; set; }
|
||||
public ITagsClient Tag { get; set; }
|
||||
public ICommitsClient Commit { get; set; }
|
||||
public IReferencesClient Reference { get; set; }
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
/// </summary>
|
||||
public interface IGitDatabaseClient
|
||||
{
|
||||
IBlobsClient Blob { get; set; }
|
||||
ITagsClient Tag { get; set; }
|
||||
ICommitsClient Commit { get; set; }
|
||||
IReferencesClient Reference { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user