Skip to content

Commit

Permalink
add convention test for preview APIs (#2154)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftkey committed Mar 18, 2020
1 parent e9516bb commit 3270207
Show file tree
Hide file tree
Showing 44 changed files with 497 additions and 509 deletions.
14 changes: 7 additions & 7 deletions Octokit.Reactive/Clients/ObservableIssuesLabelsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public IObservable<Label> GetAllForIssue(string owner, string name, int number,
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Label>(ApiUrls.IssueLabels(owner, name, number), null, AcceptHeaders.LabelsApiPreview, options);
return _connection.GetAndFlattenAllPages<Label>(ApiUrls.IssueLabels(owner, name, number), options);
}

/// <summary>
Expand All @@ -87,7 +87,7 @@ public IObservable<Label> GetAllForIssue(long repositoryId, int number, ApiOptio
{
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Label>(ApiUrls.IssueLabels(repositoryId, number), null, AcceptHeaders.LabelsApiPreview, options);
return _connection.GetAndFlattenAllPages<Label>(ApiUrls.IssueLabels(repositoryId, number), options);
}

/// <summary>
Expand Down Expand Up @@ -133,7 +133,7 @@ public IObservable<Label> GetAllForRepository(string owner, string name, ApiOpti
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Label>(ApiUrls.Labels(owner, name), null, AcceptHeaders.LabelsApiPreview, options);
return _connection.GetAndFlattenAllPages<Label>(ApiUrls.Labels(owner, name), options);
}

/// <summary>
Expand All @@ -148,7 +148,7 @@ public IObservable<Label> GetAllForRepository(long repositoryId, ApiOptions opti
{
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Label>(ApiUrls.Labels(repositoryId), null, AcceptHeaders.LabelsApiPreview, options);
return _connection.GetAndFlattenAllPages<Label>(ApiUrls.Labels(repositoryId), options);
}

/// <summary>
Expand Down Expand Up @@ -197,7 +197,7 @@ public IObservable<Label> GetAllForMilestone(string owner, string name, int numb
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Label>(ApiUrls.MilestoneLabels(owner, name, number), null, AcceptHeaders.LabelsApiPreview, options);
return _connection.GetAndFlattenAllPages<Label>(ApiUrls.MilestoneLabels(owner, name, number), options);
}

/// <summary>
Expand All @@ -213,7 +213,7 @@ public IObservable<Label> GetAllForMilestone(long repositoryId, int number, ApiO
{
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Label>(ApiUrls.MilestoneLabels(repositoryId, number), null, AcceptHeaders.LabelsApiPreview, options);
return _connection.GetAndFlattenAllPages<Label>(ApiUrls.MilestoneLabels(repositoryId, number), options);
}

/// <summary>
Expand Down Expand Up @@ -499,4 +499,4 @@ public IObservable<Unit> RemoveAllFromIssue(long repositoryId, int number)
return _client.RemoveAllFromIssue(repositoryId, number).ToObservable();
}
}
}
}
10 changes: 5 additions & 5 deletions Octokit.Reactive/Clients/ObservableRepoCollaboratorsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public IObservable<User> GetAll(string owner, string name, RepositoryCollaborato
Ensure.ArgumentNotNull(request, nameof(request));
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<User>(ApiUrls.RepoCollaborators(owner, name), request.ToParametersDictionary(), AcceptHeaders.NestedTeamsPreview, options);
return _connection.GetAndFlattenAllPages<User>(ApiUrls.RepoCollaborators(owner, name), request.ToParametersDictionary(), options);
}

/// <summary>
Expand All @@ -164,7 +164,7 @@ public IObservable<User> GetAll(long repositoryId, RepositoryCollaboratorListReq
Ensure.ArgumentNotNull(request, nameof(request));
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<User>(ApiUrls.RepoCollaborators(repositoryId), request.ToParametersDictionary(), AcceptHeaders.NestedTeamsPreview, options);
return _connection.GetAndFlattenAllPages<User>(ApiUrls.RepoCollaborators(repositoryId), request.ToParametersDictionary(), options);
}

/// <summary>
Expand Down Expand Up @@ -319,7 +319,7 @@ public IObservable<bool> Add(long repositoryId, string user, CollaboratorRequest
/// </remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="user">The username of the prospective collaborator</param>
/// <param name="user">The username of the prospective collaborator</param>
public IObservable<RepositoryInvitation> Invite(string owner, string name, string user)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Expand Down Expand Up @@ -372,7 +372,7 @@ public IObservable<RepositoryInvitation> Invite(long repositoryId, string user)
/// See the <a href="http://developer.github.com/v3/repos/collaborators/#list">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <param name="user">The username of the prospective collaborator</param>
/// <param name="user">The username of the prospective collaborator</param>
/// <param name="permission">The permission to set. Only valid on organization-owned repositories.</param>
public IObservable<RepositoryInvitation> Invite(long repositoryId, string user, CollaboratorRequest permission)
{
Expand Down Expand Up @@ -417,4 +417,4 @@ public IObservable<Unit> Delete(long repositoryId, string user)
return _client.Delete(repositoryId, user).ToObservable();
}
}
}
}
16 changes: 8 additions & 8 deletions Octokit.Reactive/Clients/ObservableRepositoriesClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public IObservable<Repository> Get(long repositoryId)
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
public IObservable<Repository> GetAllPublic()
{
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.AllPublicRepositories(), null, AcceptHeaders.LicensesApiPreview);
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.AllPublicRepositories());
}

/// <summary>
Expand All @@ -181,7 +181,7 @@ public IObservable<Repository> GetAllPublic(PublicRepositoryRequest request)

var url = ApiUrls.AllPublicRepositories(request.Since);

return _connection.GetAndFlattenAllPages<Repository>(url, null, AcceptHeaders.LicensesApiPreview);
return _connection.GetAndFlattenAllPages<Repository>(url);
}

/// <summary>
Expand All @@ -207,7 +207,7 @@ public IObservable<Repository> GetAllForCurrent(ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.Repositories(), null, AcceptHeaders.LicensesApiPreview, options);
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.Repositories(), options);
}

/// <summary>
Expand Down Expand Up @@ -238,7 +238,7 @@ public IObservable<Repository> GetAllForCurrent(RepositoryRequest request, ApiOp
Ensure.ArgumentNotNull(request, nameof(request));
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.Repositories(), request.ToParametersDictionary(), AcceptHeaders.LicensesApiPreview);
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.Repositories(), request.ToParametersDictionary());
}

/// <summary>
Expand All @@ -264,7 +264,7 @@ public IObservable<Repository> GetAllForUser(string login, ApiOptions options)
Ensure.ArgumentNotNullOrEmptyString(login, nameof(login));
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.Repositories(login), null, AcceptHeaders.LicensesApiPreview, options);
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.Repositories(login), null, options);
}

/// <summary>
Expand Down Expand Up @@ -292,7 +292,7 @@ public IObservable<Repository> GetAllForOrg(string organization, ApiOptions opti
Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization));
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.OrganizationRepositories(organization), null, AcceptHeaders.LicensesApiPreview, options);
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.OrganizationRepositories(organization), options);
}

/// <summary>
Expand Down Expand Up @@ -586,7 +586,7 @@ public IObservable<Team> GetAllTeams(string owner, string name, ApiOptions optio
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Team>(ApiUrls.RepositoryTeams(owner, name), null, AcceptHeaders.NestedTeamsPreview, options);
return _connection.GetAndFlattenAllPages<Team>(ApiUrls.RepositoryTeams(owner, name), options);
}

/// <summary>
Expand All @@ -602,7 +602,7 @@ public IObservable<Team> GetAllTeams(long repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Team>(ApiUrls.RepositoryTeams(repositoryId), null, AcceptHeaders.NestedTeamsPreview, options);
return _connection.GetAndFlattenAllPages<Team>(ApiUrls.RepositoryTeams(repositoryId), options);
}

/// <summary>
Expand Down
26 changes: 13 additions & 13 deletions Octokit.Reactive/Clients/ObservableRepositoryInvitationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public ObservableRepositoryInvitationsClient(IGitHubClient client)
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/invitations/#accept-a-repository-invitation">API documentation</a> for more information.
/// </remarks>
/// <param name="invitationId">The id of the invitation.</param>
/// </remarks>
/// <param name="invitationId">The id of the invitation.</param>
public IObservable<bool> Accept(int invitationId)
{
return _client.Accept(invitationId).ToObservable();
Expand All @@ -36,8 +36,8 @@ public IObservable<bool> Accept(int invitationId)
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/invitations/#decline-a-repository-invitation">API documentation</a> for more information.
/// </remarks>
/// <param name="invitationId">The id of the invitation.</param>
/// </remarks>
/// <param name="invitationId">The id of the invitation.</param>
public IObservable<bool> Decline(int invitationId)
{
return _client.Decline(invitationId).ToObservable();
Expand All @@ -50,7 +50,7 @@ public IObservable<bool> Decline(int invitationId)
/// See the <a href="https://developer.github.com/v3/repos/invitations/#delete-a-repository-invitation">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository.</param>
/// <param name="invitationId">The id of the invitation.</param>
/// <param name="invitationId">The id of the invitation.</param>
public IObservable<bool> Delete(long repositoryId, int invitationId)
{
return _client.Delete(repositoryId, invitationId).ToObservable();
Expand All @@ -63,7 +63,7 @@ public IObservable<bool> Delete(long repositoryId, int invitationId)
/// See the <a href="https://developer.github.com/v3/repos/invitations/#update-a-repository-invitation">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository.</param>
/// <param name="invitationId">The id of the invitatio.n</param>
/// <param name="invitationId">The id of the invitatio.n</param>
/// <param name="permissions">The permission to set.</param>
public IObservable<RepositoryInvitation> Edit(long repositoryId, int invitationId, InvitationUpdate permissions)
{
Expand All @@ -77,7 +77,7 @@ public IObservable<RepositoryInvitation> Edit(long repositoryId, int invitationI
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/invitations/#list-a-users-repository-invitations">API documentation</a> for more information.
/// </remarks>
/// </remarks>
public IObservable<RepositoryInvitation> GetAllForCurrent()
{
return GetAllForCurrent(ApiOptions.None);
Expand All @@ -89,20 +89,20 @@ public IObservable<RepositoryInvitation> GetAllForCurrent()
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/invitations/#list-a-users-repository-invitations">API documentation</a> for more information.
/// </remarks>
/// <param name="options">Options for changing the API response</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<RepositoryInvitation> GetAllForCurrent(ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return _connection.GetAndFlattenAllPages<RepositoryInvitation>(ApiUrls.UserInvitations(), null, AcceptHeaders.InvitationsApiPreview, options);
return _connection.GetAndFlattenAllPages<RepositoryInvitation>(ApiUrls.UserInvitations(), null, null, options);
}

/// <summary>
/// Gets all the invitations on a repository.
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/invitations/#list-invitations-for-a-repository">API documentation</a> for more information.
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
public IObservable<RepositoryInvitation> GetAllForRepository(long repositoryId)
{
return GetAllForRepository(repositoryId, ApiOptions.None);
Expand All @@ -113,13 +113,13 @@ public IObservable<RepositoryInvitation> GetAllForRepository(long repositoryId)
/// </summary>
/// <remarks>
/// See the <a href="https://developer.github.com/v3/repos/invitations/#list-invitations-for-a-repository">API documentation</a> for more information.
/// </remarks>
/// </remarks>
/// <param name="repositoryId">The id of the repository</param>
/// <param name="options">Options for changing the API response</param>
public IObservable<RepositoryInvitation> GetAllForRepository(long repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return _connection.GetAndFlattenAllPages<RepositoryInvitation>(ApiUrls.RepositoryInvitations(repositoryId), null, AcceptHeaders.InvitationsApiPreview, options);
return _connection.GetAndFlattenAllPages<RepositoryInvitation>(ApiUrls.RepositoryInvitations(repositoryId), null, null, options);
}
}
}
18 changes: 9 additions & 9 deletions Octokit.Reactive/Clients/ObservableTeamsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public IObservable<Team> GetAll(string org, ApiOptions options)
Ensure.ArgumentNotNullOrEmptyString(org, nameof(org));
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Team>(ApiUrls.OrganizationTeams(org), null, AcceptHeaders.NestedTeamsPreview, options);
return _connection.GetAndFlattenAllPages<Team>(ApiUrls.OrganizationTeams(org), options);
}

/// <summary>
Expand All @@ -87,7 +87,7 @@ public IObservable<Team> GetAllForCurrent(ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Team>(ApiUrls.UserTeams(), null, AcceptHeaders.NestedTeamsPreview, options);
return _connection.GetAndFlattenAllPages<Team>(ApiUrls.UserTeams(), options);
}

/// <summary>
Expand All @@ -114,11 +114,11 @@ public IObservable<Team> GetAllChildTeams(int id, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Team>(ApiUrls.TeamChildTeams(id), null, AcceptHeaders.NestedTeamsPreview, options);
return _connection.GetAndFlattenAllPages<Team>(ApiUrls.TeamChildTeams(id), options);
}

/// <summary>
/// Returns all members of the given team.
/// Returns all members of the given team.
/// </summary>
/// <param name="id">The team identifier</param>
/// <remarks>
Expand All @@ -132,7 +132,7 @@ public IObservable<User> GetAllMembers(int id)
}

/// <summary>
/// Returns all members of the given team.
/// Returns all members of the given team.
/// </summary>
/// <remarks>
/// https://developer.github.com/v3/orgs/teams/#list-team-members
Expand All @@ -145,7 +145,7 @@ public IObservable<User> GetAllMembers(int id, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<User>(ApiUrls.TeamMembers(id), null, AcceptHeaders.NestedTeamsPreview, options);
return _connection.GetAndFlattenAllPages<User>(ApiUrls.TeamMembers(id), options);
}

/// <summary>
Expand Down Expand Up @@ -177,7 +177,7 @@ public IObservable<User> GetAllMembers(int id, TeamMembersRequest request, ApiOp
Ensure.ArgumentNotNull(request, nameof(request));
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<User>(ApiUrls.TeamMembers(id), request.ToParametersDictionary(), AcceptHeaders.NestedTeamsPreview, options);
return _connection.GetAndFlattenAllPages<User>(ApiUrls.TeamMembers(id), request.ToParametersDictionary(), options);
}

/// <summary>
Expand Down Expand Up @@ -249,7 +249,7 @@ public IObservable<bool> RemoveMembership(int id, string login)
}

/// <summary>
/// Gets whether the user with the given <paramref name="login"/>
/// Gets whether the user with the given <paramref name="login"/>
/// is a member of the team with the given <paramref name="id"/>.
/// A <see cref="NotFoundException"/> is thrown if the user is not a member.
/// </summary>
Expand Down Expand Up @@ -286,7 +286,7 @@ public IObservable<Repository> GetAllRepositories(int id, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.TeamRepositories(id), null, AcceptHeaders.NestedTeamsPreview, options);
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.TeamRepositories(id), options);
}

/// <summary>
Expand Down

0 comments on commit 3270207

Please sign in to comment.