Skip to content

Commit b083bd2

Browse files
test: accepts meta in data of atomic ADD resource request
1 parent 7c768eb commit b083bd2

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

test/JsonApiDotNetCoreTests/IntegrationTests/Meta/RequestMetaTests.cs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,55 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
506506
ValidateMetaData(relationship.Meta);
507507
}
508508

509+
[Fact]
510+
public async Task Accepts_meta_in_data_of_atomic_add_resource_operation()
511+
{
512+
// Arrange
513+
var store = _testContext.Factory.Services.GetRequiredService<RequestDocumentStore>();
514+
515+
SupportTicket existingTicket = _fakers.SupportTicket.GenerateOne();
516+
517+
var requestBody = new
518+
{
519+
atomic__operations = new[]
520+
{
521+
new
522+
{
523+
op = "add",
524+
data = new
525+
{
526+
type = "supportTickets",
527+
attributes = new
528+
{
529+
description = existingTicket.Description
530+
},
531+
meta = GetExampleMetaData()
532+
}
533+
}
534+
}
535+
};
536+
537+
string route = $"/operations";
538+
539+
// Act
540+
(HttpResponseMessage httpResponse, _) = await _testContext.ExecutePostAtomicAsync<Document>(route, requestBody);
541+
542+
// Assert
543+
httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK);
544+
545+
store.Document.Should().NotBeNull();
546+
store.Document.Operations.Should().NotBeNull();
547+
store.Document.Operations.Should().HaveCount(1);
548+
549+
var operation = store.Document.Operations[0];
550+
operation.Should().NotBeNull();
551+
operation.Data.Should().NotBeNull();
552+
operation.Data.SingleValue.Should().NotBeNull();
553+
operation.Data.SingleValue.Meta.Should().NotBeNull();
554+
555+
ValidateMetaData(operation.Data.SingleValue.Meta);
556+
}
557+
509558
private static Object GetExampleMetaData()
510559
{
511560
return new

0 commit comments

Comments
 (0)