forked from ravendb/ravendb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RavenDB-14041 : AttachmentStorage.Put - do not throw a concurrency ex…
…ception on partial update with a valid expected change vector
- Loading branch information
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System.IO; | ||
using Raven.Client.Documents.Commands.Batches; | ||
using SlowTests.Core.Utils.Entities; | ||
using Tests.Infrastructure; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace SlowTests.Issues | ||
{ | ||
public class RavenDB_14041 : ClusterTestBase | ||
{ | ||
public RavenDB_14041(ITestOutputHelper output) : base(output) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public void CanUpdateAttachmentUsingPutAttachmentCommandDataWithExpectedChangeVector() | ||
{ | ||
using (var store = GetDocumentStore()) | ||
{ | ||
const string documentId = "cats/1-A"; | ||
const string name = "bruhhh"; | ||
const string contentType = "stuff"; | ||
|
||
using (var session = store.OpenSession()) | ||
{ | ||
session.Store(new User(), documentId); | ||
|
||
using var stream = new MemoryStream(new byte[] { 1, 2, 3, 4, 5 }); | ||
session.Advanced.Attachments.Store(documentId, name, stream, contentType); | ||
|
||
session.SaveChanges(); | ||
} | ||
|
||
// update attachment | ||
using (var session = store.OpenSession()) | ||
{ | ||
var attachment = session.Advanced.Attachments.Get(documentId, name); | ||
using var stream = new MemoryStream(new byte[] { 6, 7, 8, 9, 10 }); | ||
|
||
// should not throw a concurrency exception | ||
var cmd = new PutAttachmentCommandData(documentId, name, stream, contentType, changeVector: attachment.Details.ChangeVector); | ||
session.Advanced.Defer(cmd); | ||
session.SaveChanges(); | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
} |