Skip to content

Commit

Permalink
add integration tests for extra methods on observable client
Browse files Browse the repository at this point in the history
  • Loading branch information
ryangribble committed Aug 29, 2018
1 parent 9effc1d commit bb53032
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
1 change: 1 addition & 0 deletions Octokit.Tests.Integration/Clients/GitHubAppsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public TheGetAllInstallationsForCurrentUserMethod()
{
// Need to Authenticate as User to Server but not possible without receiving redirect from github.com
//_github = Helper.GetAuthenticatedUserToServer();
_github = null;
}

[GitHubAppsTest(Skip ="Not possible to authenticate with User to Server auth")]
Expand Down
100 changes: 100 additions & 0 deletions Octokit.Tests.Integration/Reactive/ObservableGitHubAppsClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Octokit.Reactive;
Expand Down Expand Up @@ -106,6 +107,26 @@ public async Task GetsInstallation()
}
}

public class TheGetAllInstallationsForCurrentUserMethod
{
IObservableGitHubClient _github;

public TheGetAllInstallationsForCurrentUserMethod()
{
// Need to Authenticate as User to Server but not possible without receiving redirect from github.com
//_github = new ObservableGitHubClient(Helper.GetAuthenticatedUserToServer());
_github = null;
}

[GitHubAppsTest(Skip = "Not possible to authenticate with User to Server auth")]
public async Task GetsAllInstallationsForCurrentUser()
{
var result = await _github.GitHubApps.GetAllInstallationsForCurrentUser();

Assert.NotNull(result);
}
}

public class TheCreateInstallationTokenMethod
{
IObservableGitHubClient _github;
Expand All @@ -129,5 +150,84 @@ public async Task CreatesInstallationToken()
Assert.True(DateTimeOffset.Now < result.ExpiresAt);
}
}

public class TheGetOrganizationInstallationForCurrentMethod
{
IObservableGitHubClient _github;

public TheGetOrganizationInstallationForCurrentMethod()
{
// Authenticate as a GitHubApp
_github = new ObservableGitHubClient(Helper.GetAuthenticatedGitHubAppsClient());
}

[GitHubAppsTest]
public async Task GetsOrganizationInstallations()
{
var result = await _github.GitHubApps.GetOrganizationInstallationForCurrent(Helper.Organization);

Assert.NotNull(result);
}
}

public class TheGetRepositoryInstallationForCurrentMethod
{
IObservableGitHubClient _github;
IObservableGitHubClient _githubAppInstallation;

public TheGetRepositoryInstallationForCurrentMethod()
{
// Autheticate as a GitHubApp
_github = new ObservableGitHubClient(Helper.GetAuthenticatedGitHubAppsClient());

// Authenticate as a GitHubApp Installation
_githubAppInstallation = new ObservableGitHubClient(Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName));
}

[GitHubAppsTest]
public async Task GetsRepositoryInstallations()
{
// Find a repo under the installation
var repos = await _githubAppInstallation.GitHubApps.Installation.GetAllRepositoriesForCurrent();
var repo = repos.Repositories.First();

// Now, using the GitHub App auth, find this repository installation
var result = await _github.GitHubApps.GetRepositoryInstallationForCurrent(repo.Owner.Login, repo.Name);

Assert.NotNull(result);
}

[GitHubAppsTest]
public async Task GetsRepositoryInstallationsWithRepositoryId()
{
// Find a repo under the installation
var repos = await _githubAppInstallation.GitHubApps.Installation.GetAllRepositoriesForCurrent();
var repo = repos.Repositories.First();

// Now, using the GitHub App auth, find this repository installation
var result = await _github.GitHubApps.GetRepositoryInstallationForCurrent(repo.Id);

Assert.NotNull(result);
}
}

public class TheGetUserInstallationForCurrentMethod
{
IObservableGitHubClient _github;

public TheGetUserInstallationForCurrentMethod()
{
// Authenticate as a GitHubApp
_github = new ObservableGitHubClient(Helper.GetAuthenticatedGitHubAppsClient());
}

[GitHubAppsTest]
public async Task GetsUserInstallations()
{
var result = await _github.GitHubApps.GetUserInstallationForCurrent(Helper.UserName);

Assert.NotNull(result);
}
}
}
}

0 comments on commit bb53032

Please sign in to comment.