Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix]: The methods GetAllForCurrentWithTimestamps and GetAllForUserWithTimestamps did not return timestamps. #2829

Merged
merged 5 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Octokit.Tests.Integration/Clients/StarredClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ public async Task CanGetAllForCurrentWithTimestamps()

var repo = stars.FirstOrDefault(star => star.Repo.Owner.Login == _repositoryContext.RepositoryOwner && star.Repo.Name == _repositoryContext.RepositoryName);
Assert.NotNull(repo);
Assert.NotEqual(DateTimeOffset.MinValue, repo.StarredAt);
Assert.NotNull(repo.Repo);
}

[IntegrationTest]
Expand Down Expand Up @@ -232,6 +234,8 @@ public async Task CanGetAllForCurrentWithTimestampsParameterized()

var repo = stars.FirstOrDefault(star => star.Repo.Owner.Login == _repositoryContext.RepositoryOwner && star.Repo.Name == _repositoryContext.RepositoryName);
Assert.NotNull(repo);
Assert.NotEqual(DateTimeOffset.MinValue, repo.StarredAt);
Assert.NotNull(repo.Repo);

for (int i = 1; i < stars.Count; i++)
{
Expand Down Expand Up @@ -456,6 +460,8 @@ public async Task CanGetAllForUserWithTimestamps()

var star = stars.FirstOrDefault(repositoryStar => repositoryStar.Repo.Owner.Login == _repositoryContext.RepositoryOwner && repositoryStar.Repo.Name == _repositoryContext.RepositoryName);
Assert.NotNull(star);
Assert.NotEqual(DateTimeOffset.MinValue, star.StarredAt);
Assert.NotNull(star.Repo);
}

[IntegrationTest]
Expand Down Expand Up @@ -521,6 +527,8 @@ public async Task CanGetAllForUserWithTimestampsParameterized()

var repo = stars.FirstOrDefault(repository => repository.Repo.Owner.Login == _repositoryContext.RepositoryOwner && repository.Repo.Name == _repositoryContext.RepositoryName);
Assert.NotNull(repo);
Assert.NotEqual(DateTimeOffset.MinValue, repo.StarredAt);
Assert.NotNull(repo.Repo);

for (int i = 1; i < stars.Count; i++)
{
Expand Down
16 changes: 8 additions & 8 deletions Octokit.Tests/Clients/StarredClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public async Task RequestsCorrectUrlWithTimestamps()

await client.GetAllForCurrentWithTimestamps();

connection.Received().GetAll<RepositoryStar>(endpoint, null, Args.ApiOptions);
connection.Received().GetAll<RepositoryStar>(endpoint, null, AcceptHeaders.StarJson, Args.ApiOptions);
}

[Fact]
Expand All @@ -118,7 +118,7 @@ public async Task RequestsCorrectUrlWithTimestampsWithApiOptions()

await client.GetAllForCurrentWithTimestamps(options);

connection.Received().GetAll<RepositoryStar>(endpoint, null, options);
connection.Received().GetAll<RepositoryStar>(endpoint, null, AcceptHeaders.StarJson, options);
}

[Fact]
Expand All @@ -132,7 +132,7 @@ public async Task RequestsCorrectUrlWithTimestampsParametrized()

await client.GetAllForCurrentWithTimestamps(request);

connection.Received().GetAll<RepositoryStar>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), Args.ApiOptions);
connection.Received().GetAll<RepositoryStar>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), AcceptHeaders.StarJson, Args.ApiOptions);
}

[Fact]
Expand All @@ -153,7 +153,7 @@ public async Task RequestsCorrectUrlWithTimestampsParametrizedWithApiOptions()

await client.GetAllForCurrentWithTimestamps(request, options);

connection.Received().GetAll<RepositoryStar>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), options);
connection.Received().GetAll<RepositoryStar>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), AcceptHeaders.StarJson, options);
}

[Fact]
Expand Down Expand Up @@ -250,7 +250,7 @@ public async Task RequestsCorrectUrlWithTimestamps()

await client.GetAllForUserWithTimestamps("banana");

connection.Received().GetAll<RepositoryStar>(endpoint, null, Args.ApiOptions);
connection.Received().GetAll<RepositoryStar>(endpoint, null, AcceptHeaders.StarJson, Args.ApiOptions);
}

[Fact]
Expand All @@ -269,7 +269,7 @@ public async Task RequestsCorrectUrlWithTimestampsWithApiOptions()

await client.GetAllForUserWithTimestamps("banana", options);

connection.Received().GetAll<RepositoryStar>(endpoint, null, options);
connection.Received().GetAll<RepositoryStar>(endpoint, null, AcceptHeaders.StarJson, options);
}

[Fact]
Expand All @@ -283,7 +283,7 @@ public async Task RequestsCorrectUrlWithTimestampsParametrized()

await client.GetAllForUserWithTimestamps("banana", starredRequest);

connection.Received().GetAll<RepositoryStar>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), Args.ApiOptions);
connection.Received().GetAll<RepositoryStar>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), AcceptHeaders.StarJson, Args.ApiOptions);
}

[Fact]
Expand All @@ -304,7 +304,7 @@ public async Task RequestsCorrectUrlWithTimestampsParametrizedWithApiOptions()

await client.GetAllForUserWithTimestamps("banana", starredRequest, options);

connection.Received().GetAll<RepositoryStar>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), options);
connection.Received().GetAll<RepositoryStar>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc"), AcceptHeaders.StarJson, options);
}

[Fact]
Expand Down
8 changes: 4 additions & 4 deletions Octokit/Clients/StarredClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public Task<IReadOnlyList<RepositoryStar>> GetAllForCurrentWithTimestamps(ApiOpt
{
Ensure.ArgumentNotNull(options, nameof(options));

return ApiConnection.GetAll<RepositoryStar>(ApiUrls.Starred(), null, options);
return ApiConnection.GetAll<RepositoryStar>(ApiUrls.Starred(), null, AcceptHeaders.StarJson, options);
}

/// <summary>
Expand Down Expand Up @@ -237,7 +237,7 @@ public Task<IReadOnlyList<RepositoryStar>> GetAllForCurrentWithTimestamps(Starre
Ensure.ArgumentNotNull(request, nameof(request));
Ensure.ArgumentNotNull(options, nameof(options));

return ApiConnection.GetAll<RepositoryStar>(ApiUrls.Starred(), request.ToParametersDictionary(), options);
return ApiConnection.GetAll<RepositoryStar>(ApiUrls.Starred(), request.ToParametersDictionary(), AcceptHeaders.StarJson, options);
}

/// <summary>
Expand Down Expand Up @@ -293,7 +293,7 @@ public Task<IReadOnlyList<RepositoryStar>> GetAllForUserWithTimestamps(string us
Ensure.ArgumentNotNullOrEmptyString(user, nameof(user));
Ensure.ArgumentNotNull(options, nameof(options));

return ApiConnection.GetAll<RepositoryStar>(ApiUrls.StarredByUser(user), null, options);
return ApiConnection.GetAll<RepositoryStar>(ApiUrls.StarredByUser(user), null, AcceptHeaders.StarJson, options);
}

/// <summary>
Expand Down Expand Up @@ -359,7 +359,7 @@ public Task<IReadOnlyList<RepositoryStar>> GetAllForUserWithTimestamps(string us
Ensure.ArgumentNotNull(request, nameof(request));
Ensure.ArgumentNotNull(options, nameof(options));

return ApiConnection.GetAll<RepositoryStar>(ApiUrls.StarredByUser(user), request.ToParametersDictionary(), options);
return ApiConnection.GetAll<RepositoryStar>(ApiUrls.StarredByUser(user), request.ToParametersDictionary(), AcceptHeaders.StarJson, options);
}

/// <summary>
Expand Down
Loading