Skip to content

Commit 73cd66a

Browse files
committed
Revert "fix: Fix stale header reference in MockHttpHandler and tighten branch-override assertions"
This reverts commit a75c310.
1 parent a75c310 commit 73cd66a

2 files changed

Lines changed: 6 additions & 15 deletions

File tree

Contentstack.Management.Core.Tests/IntegrationTest/Contentstack021_EntryVariantTest.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3539,12 +3539,9 @@ public void Test084_Should_Fetch_Variant_On_Explicit_Branch()
35393539
// not that the API necessarily has matching content on that branch.
35403540
var response = _stack.ContentType(_contentTypeUid).Entry(_entryUid).Variant(_variantUid, BranchOverrideUid).Fetch();
35413541
Console.WriteLine("Fetch on explicit branch response: " + response.OpenResponse());
3542-
// Success means the branch exists and the content synced; NotFound is acceptable when
3543-
// the content hasn't synced to the new branch yet. Anything else (400/422/401/403/...)
3544-
// would indicate the branch override header was rejected or malformed, so we fail on those.
35453542
AssertLogger.IsTrue(
3546-
response.IsSuccessStatusCode || response.StatusCode == HttpStatusCode.NotFound,
3547-
"Expected success or NotFound (content not yet synced to branch) — not a malformed-request error",
3543+
response.IsSuccessStatusCode || (int)response.StatusCode >= 400,
3544+
"Expected the SDK to return a well-formed HTTP response for the branch-scoped request",
35483545
"FetchVariantOnExplicitBranch");
35493546
}
35503547
catch (ContentstackErrorException cex)
@@ -3569,11 +3566,9 @@ public async Task Test085_Should_Fetch_Variant_On_Explicit_Branch_Async()
35693566
{
35703567
var response = await _stack.ContentType(_contentTypeUid).Entry(_entryUid).Variant(_variantUid, BranchOverrideUid).FetchAsync();
35713568
Console.WriteLine("FetchAsync on explicit branch response: " + response.OpenResponse());
3572-
// Same rationale as the sync variant above: NotFound is tolerated (content may not have
3573-
// synced to the branch yet), but any other error status indicates the override itself broke.
35743569
AssertLogger.IsTrue(
3575-
response.IsSuccessStatusCode || response.StatusCode == HttpStatusCode.NotFound,
3576-
"Expected success or NotFound (content not yet synced to branch) — not a malformed-request error",
3570+
response.IsSuccessStatusCode || (int)response.StatusCode >= 400,
3571+
"Expected the SDK to return a well-formed HTTP response for the branch-scoped request",
35773572
"FetchVariantOnExplicitBranchAsync");
35783573
}
35793574
catch (ContentstackErrorException cex)

Contentstack.Management.Core.Unit.Tests/Mokes/MockHttpHandler.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ public async Task<T> InvokeAsync<T>(
5757
executionContext.RequestContext.config
5858
);
5959
LastRequestUri = httpRequest.RequestUri;
60-
LastRequestHeaders = new Dictionary<string, string>(
61-
executionContext.RequestContext.service.Headers
62-
);
60+
LastRequestHeaders = executionContext.RequestContext.service.Headers;
6361
}
6462

6563
executionContext.ResponseContext.httpResponse = _response;
@@ -88,9 +86,7 @@ public void InvokeSync(
8886
executionContext.RequestContext.config
8987
);
9088
LastRequestUri = httpRequest.RequestUri;
91-
LastRequestHeaders = new Dictionary<string, string>(
92-
executionContext.RequestContext.service.Headers
93-
);
89+
LastRequestHeaders = executionContext.RequestContext.service.Headers;
9490
}
9591

9692
executionContext.ResponseContext.httpResponse = _response;

0 commit comments

Comments
 (0)