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

[bug]: GetAllStargazersWithTimestamps was not returning timestamps #2785

Merged
merged 8 commits into from
Sep 26, 2023
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
4 changes: 2 additions & 2 deletions Octokit.Reactive/Clients/ObservableStarredClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public IObservable<UserStar> GetAllStargazersWithTimestamps(string owner, string
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<UserStar>(ApiUrls.Stargazers(owner, name), null, options);
return _connection.GetAndFlattenAllPages<UserStar>(ApiUrls.Stargazers(owner, name), null, AcceptHeaders.StarJson, options);
}

/// <summary>
Expand All @@ -126,7 +126,7 @@ public IObservable<UserStar> GetAllStargazersWithTimestamps(long repositoryId, A
{
Ensure.ArgumentNotNull(options, nameof(options));

return _connection.GetAndFlattenAllPages<UserStar>(ApiUrls.Stargazers(repositoryId), null, options);
return _connection.GetAndFlattenAllPages<UserStar>(ApiUrls.Stargazers(repositoryId), null, AcceptHeaders.StarJson, options);
}

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions Octokit.Tests.Integration/Clients/StarredClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,9 @@ public async Task CanGetAllStargazersWithTimestamps()

var userStar = users.FirstOrDefault(star => star.User.Login == _repositoryContext.RepositoryOwner);
Assert.NotNull(userStar);
Assert.NotEqual(DateTimeOffset.MinValue, userStar.StarredAt);
Assert.NotNull(userStar.User);
Assert.NotNull(userStar.User.Login);

Assert.True(DateTimeOffset.UtcNow.Subtract(userStar.StarredAt) < TimeSpan.FromMinutes(5));
}
Expand Down
8 changes: 4 additions & 4 deletions Octokit.Tests/Clients/StarredClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public async Task RequestsCorrectUrlWithTimestamps()

await client.GetAllStargazersWithTimestamps("fake", "repo");

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

[Fact]
Expand All @@ -424,7 +424,7 @@ public async Task RequestsCorrectUrlWithTimestampsWithRepositoryId()

await client.GetAllStargazersWithTimestamps(1);

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

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

await client.GetAllStargazersWithTimestamps("fake", "repo", options);

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

[Fact]
Expand All @@ -462,7 +462,7 @@ public async Task RequestsCorrectUrlWithTimestampsWithApiOptionsWithRepositoryId

await client.GetAllStargazersWithTimestamps(1, options);

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

[Fact]
Expand Down
8 changes: 4 additions & 4 deletions Octokit.Tests/Reactive/ObservableStarredClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void RequestsCorrectUrlWithTimestamps()

client.GetAllStargazersWithTimestamps("fight", "club");

connection.Received().Get<List<UserStar>>(endpoint, Args.EmptyDictionary);
connection.Received().Get<List<UserStar>>(endpoint, Args.EmptyDictionary, AcceptHeaders.StarJson);
}

[Fact]
Expand All @@ -116,7 +116,7 @@ public void RequestsCorrectUrlWithTimestampsWithRepositoryId()

client.GetAllStargazersWithTimestamps(1);

connection.Received().Get<List<UserStar>>(endpoint, Args.EmptyDictionary);
connection.Received().Get<List<UserStar>>(endpoint, Args.EmptyDictionary, AcceptHeaders.StarJson);
}

[Fact]
Expand All @@ -137,7 +137,7 @@ public void RequestsCorrectUrlWithTimestampsWithApiOptions()

client.GetAllStargazersWithTimestamps("fight", "club", options);

connection.Received().Get<List<UserStar>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2));
connection.Received().Get<List<UserStar>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2), AcceptHeaders.StarJson);
}

[Fact]
Expand All @@ -158,7 +158,7 @@ public void RequestsCorrectUrlWithTimestampsWithApiOptionsWithRepositoryId()

client.GetAllStargazersWithTimestamps(1, options);

connection.Received().Get<List<UserStar>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2));
connection.Received().Get<List<UserStar>>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2), AcceptHeaders.StarJson);
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions Octokit/Clients/StarredClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public Task<IReadOnlyList<UserStar>> GetAllStargazersWithTimestamps(string owner
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));

return ApiConnection.GetAll<UserStar>(ApiUrls.Stargazers(owner, name), null, options);
return ApiConnection.GetAll<UserStar>(ApiUrls.Stargazers(owner, name), null, AcceptHeaders.StarJson, options);
}

/// <summary>
Expand All @@ -131,7 +131,7 @@ public Task<IReadOnlyList<UserStar>> GetAllStargazersWithTimestamps(long reposit
{
Ensure.ArgumentNotNull(options, nameof(options));

return ApiConnection.GetAll<UserStar>(ApiUrls.Stargazers(repositoryId), null, options);
return ApiConnection.GetAll<UserStar>(ApiUrls.Stargazers(repositoryId), null, AcceptHeaders.StarJson, options);
}

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions Octokit/Helpers/AcceptHeaders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ public static class AcceptHeaders
public const string RawContentMediaType = "application/vnd.github.v3.raw";

public const string RepositoryContentMediaType = "application/vnd.github.v3.repository+json";

public const string StarJson = "application/vnd.github.v3.star+json";
}
}
Loading