From 112036dda91222d12e7c5527e0872d04bc6b7cab Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Fri, 10 Jun 2016 20:05:40 +0700 Subject: [PATCH] added new integration tests --- .../Clients/TagsClientTests.cs | 112 ++++++++++++++++++ .../Octokit.Tests.Integration.csproj | 1 + 2 files changed, 113 insertions(+) create mode 100644 Octokit.Tests.Integration/Clients/TagsClientTests.cs diff --git a/Octokit.Tests.Integration/Clients/TagsClientTests.cs b/Octokit.Tests.Integration/Clients/TagsClientTests.cs new file mode 100644 index 00000000..dd961b6a --- /dev/null +++ b/Octokit.Tests.Integration/Clients/TagsClientTests.cs @@ -0,0 +1,112 @@ +using System.Threading.Tasks; +using Octokit.Tests.Integration.Helpers; +using Xunit; + +namespace Octokit.Tests.Integration.Clients +{ + public class TagsClientTests + { + public class TheCreateMethod + { + readonly RepositoryContext context; + readonly ITagsClient fixture; + readonly string sha; + + public TheCreateMethod() + { + var github = Helper.GetAuthenticatedClient(); + + fixture = github.Git.Tag; + context = github.CreateRepositoryContext("public-repo").Result; + + var blob = new NewBlob + { + Content = "Hello World!", + Encoding = EncodingType.Utf8 + }; + var blobResult = github.Git.Blob.Create(context.RepositoryOwner, context.RepositoryName, blob).Result; + + sha = blobResult.Sha; + } + + [IntegrationTest] + public async Task CreatesTagForRepository() + { + var newTag = new NewTag { Message = "Hello", Type = TaggedType.Blob, Object = sha, Tag = "tag" }; + + var tag = await fixture.Create(context.Repository.Id, newTag); + + Assert.Equal(tag.Object.Type, TaggedType.Blob); + Assert.Equal(tag.Message, "Hello"); + Assert.Equal(tag.Object.Sha, sha); + } + + [IntegrationTest] + public async Task CreatesTagForRepositoryWithRepositoryId() + { + var newTag = new NewTag { Message = "Hello", Type = TaggedType.Tree, Object = sha, Tag = "tag" }; + + var tag = await fixture.Create(context.Repository.Id, newTag); + + Assert.Equal(tag.Object.Type, TaggedType.Blob); + Assert.Equal(tag.Message, "Hello"); + Assert.Equal(tag.Object.Sha, sha); + } + } + + public class TheGetMethod + { + readonly RepositoryContext context; + readonly ITagsClient fixture; + readonly string sha; + + public TheGetMethod() + { + var github = Helper.GetAuthenticatedClient(); + + fixture = github.Git.Tag; + context = github.CreateRepositoryContext("public-repo").Result; + + var blob = new NewBlob + { + Content = "Hello World!", + Encoding = EncodingType.Utf8 + }; + var blobResult = github.Git.Blob.Create(context.RepositoryOwner, context.RepositoryName, blob).Result; + + sha = blobResult.Sha; + } + + [IntegrationTest] + public async Task CreatesTagForRepository() + { + var newTag = new NewTag { Message = "Hello", Type = TaggedType.Blob, Object = sha, Tag = "tag" }; + + var tag = await fixture.Create(context.RepositoryOwner, context.RepositoryName, newTag); + var gitTag = await fixture.Get(context.RepositoryOwner, context.RepositoryName, tag.Sha); + + Assert.NotNull(gitTag); + Assert.Equal(gitTag.Object.Type, TaggedType.Blob); + Assert.Equal(gitTag.Message, "Hello"); + Assert.Equal(gitTag.Object.Sha, sha); + } + + [IntegrationTest] + public async Task CreatesTagForRepositoryWithRepositoryId() + { + var github = Helper.GetAuthenticatedClient(); + + var newTag = new NewTag { Message = "Hello", Type = TaggedType.Blob, Object = sha, Tag = "tag" }; + + var tag = await github.Git.Tag.Create(context.Repository.Id, newTag); + + var gitTag = await github.Git.Tag.Get(context.Repository.Id, tag.Sha); + + Assert.NotNull(gitTag); + Assert.Equal(gitTag.Object.Type, TaggedType.Blob); + Assert.Equal(gitTag.Message, "Hello"); + Assert.Equal(gitTag.Object.Sha, sha); + } + } + } +} diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 6748e034..8a8267db 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -108,6 +108,7 @@ +