Skip to content

Commit

Permalink
[Fix]: The methods GetAllForCurrentWithTimestamps and `GetAllForUse…
Browse files Browse the repository at this point in the history
…rWithTimestamps` now return timestamps.

* Fix unit tests.

* Fix integration tests.

* Fix to use `AcceptHeaders.StarJson`.

---------

Co-authored-by: Nick Floyd <[email protected]>
  • Loading branch information
MareMare and nickfloyd committed Jan 2, 2024
1 parent f9c5b69 commit 3e92a69
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
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

0 comments on commit 3e92a69

Please sign in to comment.