Skip to content

Commit

Permalink
chore: Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MH321Productions committed Feb 27, 2025
1 parent 4f5f0fa commit 4642fd8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ User requests available Tags
And the response attributes contain tags

Scenario: Requesting the tags with the current hash
Given the most current hash h
When A GET request to the /Tags endpoint gets sent with hash h
Given a list of tags l with an ETag e
And I didn't change since the last fetch
When A GET request to the /Tags endpoint gets sent with the If-None-Match header set to e
Then the response status code is 304 (Not modified)
And the response content is empty
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,28 @@ public class TagsStepDefinitions
{
private readonly ResponseContext _responseContext;
private readonly ClientPool _clientPool;
private readonly TagsContext _tagsContext;

private CachedApiResponse<ListTagsResponse>? _listTagsResponse;

public TagsStepDefinitions(ResponseContext responseContext, ClientPool clientPool)
{
_responseContext = responseContext;
_clientPool = clientPool;
_tagsContext = new TagsContext();
}

#region Given

[Given($@"the most current hash {RegexFor.SINGLE_THING}")]
public async Task GivenTheMostCurrentHash(string hash)
[Given($@"a list of tags {RegexFor.SINGLE_THING} with an ETag {RegexFor.SINGLE_THING}")]
public async Task GivenAListOfTagsWithETag(string list, string hash)
{
await WhenAGETRequestToTheTagsEndpointGetsSent();

_listTagsResponse!.Should().BeASuccess();
}

_tagsContext.TagHashes[hash] = _listTagsResponse!.ETag;
[Given("I didn't change since the last fetch")]
public void GivenIDidntChangeSinceLastFetch()
{
}

#endregion
Expand All @@ -46,11 +47,11 @@ public async Task WhenAGETRequestToTheTagsEndpointGetsSent()
_responseContext.WhenResponse = _listTagsResponse = await client.Tags.ListTags();
}

[When($@"A GET request to the /Tags endpoint gets sent with hash {RegexFor.SINGLE_THING}")]
[When($@"A GET request to the /Tags endpoint gets sent with the If-None-Match header set to {RegexFor.SINGLE_THING}")]
public async Task WhenAGETRequestToTheTagsEndpointGetsSentWithHash(string hash)
{
var client = _clientPool.Anonymous;
_responseContext.WhenResponse = _listTagsResponse = await client.Tags.ListTags(new CacheControl { ETag = _tagsContext.TagHashes[hash] });
_responseContext.WhenResponse = _listTagsResponse = await client.Tags.ListTags(new CacheControl { ETag = _listTagsResponse!.ETag });
}

#endregion
Expand All @@ -72,5 +73,12 @@ public void AndTheResponseAttributesContainTags()
}
}

[Then("the response content is empty")]
public void ThenTheResponseContentIsEmpty()
{
_listTagsResponse!.NotModified.Should().BeTrue();
_listTagsResponse!.Result.Should().BeNull();
}

#endregion
}
2 changes: 1 addition & 1 deletion Sdks/ConsumerApi.Sdk/src/Endpoints/Tags/TagsEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public class TagsEndpoint(EndpointClient client) : ConsumerApiEndpoint(client)
{
public async Task<CachedApiResponse<ListTagsResponse>> ListTags(CacheControl? cacheControl = null)
{
return await _client.GetCachedUnauthenticated<ListTagsResponse>($"api/{API_VERSION}/Tags", null, null, cacheControl);
return await _client.GetCachedUnauthenticated<ListTagsResponse>($"api/{API_VERSION}/Tags", cacheControl: cacheControl);
}
}

0 comments on commit 4642fd8

Please sign in to comment.