forked from octokit/octokit.net
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial implementation of Search Indexing API
- Loading branch information
1 parent
bb4086b
commit 7da92d8
Showing
18 changed files
with
545 additions
and
4 deletions.
There are no files selected for viewing
106 changes: 106 additions & 0 deletions
106
...t.Tests.Integration/Clients/Enterprise/EnterpriseOrganizationSearchIndexingClientTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Octokit; | ||
using Octokit.Tests.Integration; | ||
using Octokit.Tests.Integration.Helpers; | ||
using Xunit; | ||
|
||
public class EnterpriseOrganizationSearchIndexingClientTests | ||
{ | ||
readonly IGitHubClient _github; | ||
|
||
public EnterpriseOrganizationSearchIndexingClientTests() | ||
{ | ||
_github = EnterpriseHelper.GetAuthenticatedClient(); | ||
} | ||
|
||
[GitHubEnterpriseTest] | ||
public async Task CanQueueOwner() | ||
{ | ||
var response = await | ||
_github.Enterprise.SearchIndexing.Queue(EnterpriseHelper.UserName); | ||
|
||
Assert.NotNull(response); | ||
Assert.NotNull(response.Message); | ||
Assert.True(response.Message.All(m => m.Contains("was added to the indexing queue"))); | ||
} | ||
|
||
[GitHubEnterpriseTest] | ||
public async Task CanQueueRepository() | ||
{ | ||
var newRepository = new NewRepository(Helper.MakeNameWithTimestamp("public-repo")); | ||
using (var context = await _github.CreateRepositoryContext(newRepository)) | ||
{ | ||
var response = await | ||
_github.Enterprise.SearchIndexing.Queue(EnterpriseHelper.UserName, context.RepositoryName); | ||
|
||
Assert.NotNull(response); | ||
Assert.NotNull(response.Message); | ||
Assert.True(response.Message.All(m => m.Contains("was added to the indexing queue"))); | ||
} | ||
} | ||
|
||
[GitHubEnterpriseTest] | ||
public async Task CanQueueAll() | ||
{ | ||
var response = await | ||
_github.Enterprise.SearchIndexing.QueueAll(EnterpriseHelper.UserName); | ||
|
||
Assert.NotNull(response); | ||
Assert.NotNull(response.Message); | ||
Assert.True(response.Message.All(m => m.Contains("was added to the indexing queue"))); | ||
} | ||
|
||
[GitHubEnterpriseTest] | ||
public async Task CanQueueAllCodeOwner() | ||
{ | ||
var response = await | ||
_github.Enterprise.SearchIndexing.QueueAllCode(EnterpriseHelper.UserName); | ||
|
||
Assert.NotNull(response); | ||
Assert.NotNull(response.Message); | ||
Assert.True(response.Message.All(m => m.Contains("was added to the indexing queue"))); | ||
} | ||
|
||
[GitHubEnterpriseTest] | ||
public async Task CanQueueAllCodeRepository() | ||
{ | ||
var newRepository = new NewRepository(Helper.MakeNameWithTimestamp("public-repo")); | ||
using (var context = await _github.CreateRepositoryContext(newRepository)) | ||
{ | ||
var response = await | ||
_github.Enterprise.SearchIndexing.QueueAllCode(EnterpriseHelper.UserName, context.RepositoryName); | ||
|
||
Assert.NotNull(response); | ||
Assert.NotNull(response.Message); | ||
Assert.True(response.Message.All(m => m.Contains("was added to the indexing queue"))); | ||
} | ||
} | ||
|
||
[GitHubEnterpriseTest] | ||
public async Task CanQueueAllIssuesOwner() | ||
{ | ||
var response = await | ||
_github.Enterprise.SearchIndexing.QueueAllIssues(EnterpriseHelper.UserName); | ||
|
||
Assert.NotNull(response); | ||
Assert.NotNull(response.Message); | ||
Assert.True(response.Message.All(m => m.Contains("were added to the indexing queue"))); | ||
} | ||
|
||
[GitHubEnterpriseTest] | ||
public async Task CanQueueAllIssuesRepository() | ||
{ | ||
var newRepository = new NewRepository(Helper.MakeNameWithTimestamp("public-repo")); | ||
using (var context = await _github.CreateRepositoryContext(newRepository)) | ||
{ | ||
var response = await | ||
_github.Enterprise.SearchIndexing.QueueAllIssues(EnterpriseHelper.UserName, context.RepositoryName); | ||
|
||
Assert.NotNull(response); | ||
Assert.NotNull(response.Message); | ||
Assert.True(response.Message.All(m => m.Contains("were added to the indexing queue"))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
198 changes: 198 additions & 0 deletions
198
Octokit.Tests/Clients/Enterprise/EnterpriseSearchIndexingClientTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using NSubstitute; | ||
using Xunit; | ||
|
||
namespace Octokit.Tests.Clients | ||
{ | ||
public class EnterpriseSearchIndexingClientTests | ||
{ | ||
public class TheQueueMethod | ||
{ | ||
[Fact] | ||
public void RequestsCorrectUrl() | ||
{ | ||
var connection = Substitute.For<IApiConnection>(); | ||
var client = new EnterpriseSearchIndexingClient(connection); | ||
|
||
string expectedUri = "staff/indexing_jobs"; | ||
|
||
client.Queue("org"); | ||
connection.Received().Post<SearchIndexingResponse>(Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Any<object>()); | ||
|
||
client.Queue("org", "repo"); | ||
connection.Received().Post<SearchIndexingResponse>(Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Any<object>()); | ||
} | ||
|
||
[Fact] | ||
public void PassesRequestObject() | ||
{ | ||
var connection = Substitute.For<IApiConnection>(); | ||
var client = new EnterpriseSearchIndexingClient(connection); | ||
|
||
client.Queue("org"); | ||
connection.Received().Post<SearchIndexingResponse>( | ||
Arg.Any<Uri>(), | ||
Arg.Is<SearchIndexTarget>(t => | ||
t.Target == "org" | ||
)); | ||
|
||
client.Queue("org", "repo"); | ||
connection.Received().Post<SearchIndexingResponse>( | ||
Arg.Any<Uri>(), | ||
Arg.Is<SearchIndexTarget>(t => | ||
t.Target == "org/repo" | ||
)); | ||
} | ||
|
||
[Fact] | ||
public async Task EnsuresNonNullArguments() | ||
{ | ||
var connection = Substitute.For<IApiConnection>(); | ||
var client = new EnterpriseSearchIndexingClient(connection); | ||
|
||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Queue(null)); | ||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Queue("org", null)); | ||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Queue(null, "repo")); | ||
} | ||
} | ||
|
||
public class TheQueueAllMethod | ||
{ | ||
[Fact] | ||
public void RequestsCorrectUrl() | ||
{ | ||
var connection = Substitute.For<IApiConnection>(); | ||
var client = new EnterpriseSearchIndexingClient(connection); | ||
|
||
string expectedUri = "staff/indexing_jobs"; | ||
client.QueueAll("org"); | ||
|
||
connection.Received().Post<SearchIndexingResponse>(Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Any<object>()); | ||
} | ||
|
||
[Fact] | ||
public void PassesRequestObject() | ||
{ | ||
var connection = Substitute.For<IApiConnection>(); | ||
var client = new EnterpriseSearchIndexingClient(connection); | ||
|
||
client.QueueAll("org"); | ||
connection.Received().Post<SearchIndexingResponse>( | ||
Arg.Any<Uri>(), | ||
Arg.Is<SearchIndexTarget>(t => | ||
t.Target == "org/*" | ||
)); | ||
} | ||
|
||
[Fact] | ||
public async Task EnsuresNonNullArguments() | ||
{ | ||
var connection = Substitute.For<IApiConnection>(); | ||
var client = new EnterpriseSearchIndexingClient(connection); | ||
|
||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.QueueAll(null)); | ||
} | ||
} | ||
|
||
public class TheQueueAllCodeMethod | ||
{ | ||
[Fact] | ||
public void RequestsCorrectUrl() | ||
{ | ||
var connection = Substitute.For<IApiConnection>(); | ||
var client = new EnterpriseSearchIndexingClient(connection); | ||
|
||
string expectedUri = "staff/indexing_jobs"; | ||
|
||
client.QueueAllCode("org"); | ||
connection.Received().Post<SearchIndexingResponse>(Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Any<object>()); | ||
|
||
client.QueueAllCode("org", "repo"); | ||
connection.Received().Post<SearchIndexingResponse>(Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Any<object>()); | ||
} | ||
|
||
[Fact] | ||
public void PassesRequestObject() | ||
{ | ||
var connection = Substitute.For<IApiConnection>(); | ||
var client = new EnterpriseSearchIndexingClient(connection); | ||
|
||
client.QueueAllCode("org"); | ||
connection.Received().Post<SearchIndexingResponse>( | ||
Arg.Any<Uri>(), | ||
Arg.Is<SearchIndexTarget>(t => | ||
t.Target == "org/*/code" | ||
)); | ||
|
||
client.QueueAllCode("org", "repo"); | ||
connection.Received().Post<SearchIndexingResponse>( | ||
Arg.Any<Uri>(), | ||
Arg.Is<SearchIndexTarget>(t => | ||
t.Target == "org/repo/code" | ||
)); | ||
} | ||
|
||
[Fact] | ||
public async Task EnsuresNonNullArguments() | ||
{ | ||
var connection = Substitute.For<IApiConnection>(); | ||
var client = new EnterpriseSearchIndexingClient(connection); | ||
|
||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.QueueAllCode(null)); | ||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.QueueAllCode("org", null)); | ||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.QueueAllCode(null, "repo")); | ||
} | ||
} | ||
|
||
public class TheQueueAllIssuesMethod | ||
{ | ||
[Fact] | ||
public void RequestsCorrectUrl() | ||
{ | ||
var connection = Substitute.For<IApiConnection>(); | ||
var client = new EnterpriseSearchIndexingClient(connection); | ||
|
||
string expectedUri = "staff/indexing_jobs"; | ||
|
||
client.QueueAllIssues("org"); | ||
connection.Received().Post<SearchIndexingResponse>(Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Any<object>()); | ||
|
||
client.QueueAllIssues("org", "repo"); | ||
connection.Received().Post<SearchIndexingResponse>(Arg.Is<Uri>(u => u.ToString() == expectedUri), Arg.Any<object>()); | ||
} | ||
|
||
[Fact] | ||
public void PassesRequestObject() | ||
{ | ||
var connection = Substitute.For<IApiConnection>(); | ||
var client = new EnterpriseSearchIndexingClient(connection); | ||
|
||
client.QueueAllIssues("org"); | ||
connection.Received().Post<SearchIndexingResponse>( | ||
Arg.Any<Uri>(), | ||
Arg.Is<SearchIndexTarget>(t => | ||
t.Target == "org/*/issues" | ||
)); | ||
|
||
client.QueueAllIssues("org", "repo"); | ||
connection.Received().Post<SearchIndexingResponse>( | ||
Arg.Any<Uri>(), | ||
Arg.Is<SearchIndexTarget>(t => | ||
t.Target == "org/repo/issues" | ||
)); | ||
} | ||
|
||
[Fact] | ||
public async Task EnsuresNonNullArguments() | ||
{ | ||
var connection = Substitute.For<IApiConnection>(); | ||
var client = new EnterpriseSearchIndexingClient(connection); | ||
|
||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.QueueAllIssues(null)); | ||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.QueueAllIssues("org", null)); | ||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.QueueAllIssues(null, "repo")); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.