Skip to content

Commit

Permalink
add attribute for tracking preview usage in the codebase (#2128)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftkey authored Mar 7, 2020
1 parent 216e4e3 commit 5de5258
Show file tree
Hide file tree
Showing 46 changed files with 384 additions and 171 deletions.
2 changes: 1 addition & 1 deletion Octokit.Reactive/Clients/ObservableMigrationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ObservableMigrationsClient(IGitHubClient client)
/// https://developer.github.com/v3/migration/migrations/#start-a-migration
/// </remarks>
/// <param name="org">The organization for which to start a migration.</param>
/// <param name="migration">Sprcifies parameters for the migration in a
/// <param name="migration">Specifies parameters for the migration in a
/// <see cref="StartMigrationRequest"/> object.</param>
/// <returns>The started migration.</returns>
public IObservable<Migration> Start(string org, StartMigrationRequest migration)
Expand Down
11 changes: 7 additions & 4 deletions Octokit.Tests/Clients/AuthorizationsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Octokit.Tests.Clients
{
/// <summary>
/// Client tests mostly just need to make sure they call the IApiConnection with the correct
/// Client tests mostly just need to make sure they call the IApiConnection with the correct
/// relative Uri. No need to fake up the response. All *those* tests are in ApiConnectionTests.cs.
/// </summary>
public class AuthorizationsClientTests
Expand Down Expand Up @@ -293,7 +293,8 @@ public async Task ChecksApplicationAuthenticateAtCorrectUrl()

client.Received().Post<ApplicationAuthorization>(
Arg.Is<Uri>(u => u.ToString() == "applications/clientId/token"),
Arg.Is<Object>(o => o.GetType().GetProperty("access_token").GetValue(o).ToString() == "accessToken"));
Arg.Is<Object>(o => o.GetType().GetProperty("access_token").GetValue(o).ToString() == "accessToken"),
"application/vnd.github.doctor-strange-preview+json");
}

[Fact]
Expand Down Expand Up @@ -321,7 +322,8 @@ public async Task ResetsApplicationAuthenticationAtCorrectUrl()

client.Received().Patch<ApplicationAuthorization>(
Arg.Is<Uri>(u => u.ToString() == "applications/clientId/token"),
Arg.Is<Object>(o => o.GetType().GetProperty("access_token").GetValue(o).ToString() == "accessToken"));
Arg.Is<Object>(o => o.GetType().GetProperty("access_token").GetValue(o).ToString() == "accessToken"),
"application/vnd.github.doctor-strange-preview+json");
}

[Fact]
Expand Down Expand Up @@ -349,7 +351,8 @@ public async Task RevokesApplicationAuthenticationAtCorrectUrl()

client.Received().Delete(
Arg.Is<Uri>(u => u.ToString() == "applications/clientId/token"),
Arg.Is<Object>(o => o.GetType().GetProperty("access_token").GetValue(o).ToString() == "accessToken"));
Arg.Is<Object>(o => o.GetType().GetProperty("access_token").GetValue(o).ToString() == "accessToken"),
"application/vnd.github.doctor-strange-preview+json");
}

[Fact]
Expand Down
12 changes: 6 additions & 6 deletions Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task RequestsCorrectUrl()

await client.GetAll("fake", "repo", 42);

connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", Args.ApiOptions);
connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions);
}

[Fact]
Expand All @@ -45,7 +45,7 @@ public async Task RequestsCorrectUrlApiOptions()

await client.GetAll("fake", "repo", 42, options);

connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", options);
connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", options);
}

[Fact]
Expand All @@ -56,7 +56,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()

await client.GetAll(1, 42);

connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", Args.ApiOptions);
connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions);
}

[Fact]
Expand All @@ -74,7 +74,7 @@ public async Task RequestsCorrectUrlWithRepositoryIdApiOptions()

await client.GetAll(1, 42, options);

connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", options);
connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", options);
}

[Fact]
Expand Down Expand Up @@ -113,7 +113,7 @@ public void RequestsCorrectUrl()

client.Create("fake", "repo", 1, newReaction);

connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview");
connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview+json");
}

[Fact]
Expand All @@ -126,7 +126,7 @@ public void RequestsCorrectUrlWithRepositoryId()

client.Create(1, 1, newReaction);

connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview");
connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/comments/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview+json");
}

[Fact]
Expand Down
6 changes: 3 additions & 3 deletions Octokit.Tests/Clients/DeploymentsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void RequestsCorrectUrlWithPreviewAcceptHeaders()
connection.Received(1)
.GetAll<Deployment>(Arg.Is<Uri>(u => u.ToString() == expectedUrl),
Arg.Any<IDictionary<string, string>>(),
Arg.Is<string>(s => s == AcceptHeaders.DeploymentApiPreview),
"application/vnd.github.ant-man-preview+json",
Args.ApiOptions);
}
}
Expand Down Expand Up @@ -212,7 +212,7 @@ public void SendsPreviewAcceptHeaders()

connection.Received(1).Post<Deployment>(Arg.Any<Uri>(),
Arg.Any<NewDeployment>(),
Arg.Is<string>(s => s == AcceptHeaders.DeploymentApiPreview));
"application/vnd.github.ant-man-preview+json");
}
}

Expand All @@ -231,4 +231,4 @@ public void SetsStatusesClient()
Assert.NotNull(client.Status);
}
}
}
}
12 changes: 6 additions & 6 deletions Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public async Task RequestsCorrectUrl()

await client.GetAll("fake", "repo", 42);

connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", Args.ApiOptions);
connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions);
}

[Fact]
Expand All @@ -44,7 +44,7 @@ public async Task RequestsCorrectUrlApiOptions()

await client.GetAll("fake", "repo", 42, options);

connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", options);
connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", options);
}

[Fact]
Expand All @@ -55,7 +55,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()

await client.GetAll(1, 42);

connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", Args.ApiOptions);
connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions);
}

[Fact]
Expand All @@ -73,7 +73,7 @@ public async Task RequestsCorrectUrlWithRepositoryIdApiOptions()

await client.GetAll(1, 42, options);

connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", options);
connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", options);
}

[Fact]
Expand Down Expand Up @@ -112,7 +112,7 @@ public void RequestsCorrectUrl()

client.Create("fake", "repo", 1, newReaction);

connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview");
connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview+json");
}

[Fact]
Expand All @@ -125,7 +125,7 @@ public void RequestsCorrectUrlWithRepositoryId()

client.Create(1, 1, newReaction);

connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview");
connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview+json");
}

[Fact]
Expand Down
24 changes: 12 additions & 12 deletions Octokit.Tests/Clients/IssueCommentsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task RequestsCorrectUrl()
connection.Received().Get<IssueComment>(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/42"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview");
"application/vnd.github.squirrel-girl-preview+json");
}

[Fact]
Expand All @@ -36,7 +36,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()

connection.Received().Get<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments/42"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview");
"application/vnd.github.squirrel-girl-preview+json");
}

[Fact]
Expand Down Expand Up @@ -65,7 +65,7 @@ public async Task RequestsCorrectUrl()
connection.Received().GetAll<IssueComment>(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview",
"application/vnd.github.squirrel-girl-preview+json",
Args.ApiOptions);
}

Expand All @@ -79,7 +79,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()

connection.Received().GetAll<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview",
"application/vnd.github.squirrel-girl-preview+json",
Args.ApiOptions);
}

Expand All @@ -101,7 +101,7 @@ public async Task RequestsCorrectUrlWithApiOptions()
connection.Received().GetAll<IssueComment>(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview",
"application/vnd.github.squirrel-girl-preview+json",
options);
}

Expand All @@ -122,7 +122,7 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()

connection.Received().GetAll<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/comments"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview",
"application/vnd.github.squirrel-girl-preview+json",
options);
}

Expand Down Expand Up @@ -162,7 +162,7 @@ public async Task RequestsCorrectUrl()
connection.Received().GetAll<IssueComment>(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/3/comments"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview",
"application/vnd.github.squirrel-girl-preview+json",
Args.ApiOptions);
}

Expand All @@ -176,7 +176,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()

connection.Received().GetAll<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/3/comments"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview",
"application/vnd.github.squirrel-girl-preview+json",
Args.ApiOptions);
}

Expand All @@ -196,7 +196,7 @@ public async Task RequestsCorrectUrlWithIssueCommentRequest()
connection.Received().GetAll<IssueComment>(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/3/comments"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview",
"application/vnd.github.squirrel-girl-preview+json",
Args.ApiOptions);
}

Expand All @@ -215,7 +215,7 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithIssueCommentRequest()

connection.Received().GetAll<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/3/comments"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview",
"application/vnd.github.squirrel-girl-preview+json",
Args.ApiOptions);
}

Expand All @@ -237,7 +237,7 @@ public async Task RequestsCorrectUrlWithApiOptions()
connection.Received().GetAll<IssueComment>(
Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/3/comments"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview",
"application/vnd.github.squirrel-girl-preview+json",
options);
}

Expand All @@ -258,7 +258,7 @@ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()

connection.Received().GetAll<IssueComment>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/3/comments"),
Arg.Any<Dictionary<string, string>>(),
"application/vnd.github.squirrel-girl-preview",
"application/vnd.github.squirrel-girl-preview+json",
options);
}

Expand Down
12 changes: 6 additions & 6 deletions Octokit.Tests/Clients/IssueReactionsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public async Task RequestsCorrectUrl()

await client.GetAll("fake", "repo", 42);

connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", Args.ApiOptions);
connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions);
}

[Fact]
Expand All @@ -44,7 +44,7 @@ public async Task RequestsCorrectUrlApiOptions()

await client.GetAll("fake", "repo", 42, options);

connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", options);
connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", options);
}

[Fact]
Expand All @@ -55,7 +55,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()

await client.GetAll(1, 42);

connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", Args.ApiOptions);
connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", Args.ApiOptions);
}

[Fact]
Expand All @@ -73,7 +73,7 @@ public async Task RequestsCorrectUrlWithRepositoryIdApiOptions()

await client.GetAll(1, 42, options);

connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/reactions"), null, "application/vnd.github.squirrel-girl-preview", options);
connection.Received().GetAll<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/reactions"), null, "application/vnd.github.squirrel-girl-preview+json", options);
}

[Fact]
Expand Down Expand Up @@ -112,7 +112,7 @@ public void RequestsCorrectUrl()

client.Create("fake", "repo", 1, newReaction);

connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview");
connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview+json");
}

[Fact]
Expand All @@ -125,7 +125,7 @@ public void RequestsCorrectUrlWithRepositoryId()

client.Create(1, 1, newReaction);

connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview");
connection.Received().Post<Reaction>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/1/reactions"), newReaction, "application/vnd.github.squirrel-girl-preview+json");
}

[Fact]
Expand Down
Loading

0 comments on commit 5de5258

Please sign in to comment.