test(cv-import): verify canonical revision and preserved profile on MariaDB
This commit is contained in:
@@ -17,6 +17,31 @@ namespace JobTrackerApi.MariaDb.Tests;
|
||||
|
||||
public class CvImportReviewedPersistenceTests
|
||||
{
|
||||
private readonly Xunit.Abstractions.ITestOutputHelper _output;
|
||||
public CvImportReviewedPersistenceTests(Xunit.Abstractions.ITestOutputHelper output) => _output = output;
|
||||
|
||||
[Fact]
|
||||
public async Task Existing_profile_fields_survive_and_import_metadata_uses_the_canonical_revision()
|
||||
{
|
||||
await using var database = await MariaDbDatabase.CreateAsync();
|
||||
await using var db = database.Context();
|
||||
var run = await Seed(db);
|
||||
await new CareerProfileService(db).SaveVersionAsync(Owner, new() { Summary = { "Preserve my summary" }, Contact = new() { GitHub = "https://github.com/existing" }, OtherSections = { new() { Title = "Private", Items = { "Preserve my custom fact" } } } }, "manual", 0, default);
|
||||
(await db.Users.SingleAsync()).CurrentCvProfileVersion = 99;
|
||||
await db.SaveChangesAsync();
|
||||
var controller = Controller(db);
|
||||
var clock = System.Diagnostics.Stopwatch.StartNew();
|
||||
Assert.IsType<OkObjectResult>(await controller.ApplyReviewed(run.Id, new(1, new[] { new CvImportDecision("skills.0", "use") })));
|
||||
clock.Stop();
|
||||
_output.WriteLine("ReviewedImportApplyMs={0:F3}; provider=MariaDB12.2.2; includes=validation,merge,transaction,Identity_projection", clock.Elapsed.TotalMilliseconds);
|
||||
await using var verify = database.Context();
|
||||
var snapshot = await new CareerProfileService(verify).LoadSnapshotAsync(Owner, default);
|
||||
Assert.Equal(2, snapshot.Revision);
|
||||
Assert.Equal(2, snapshot.Profile.Metadata.ProfileVersion);
|
||||
Assert.Equal("Preserve my summary", Assert.Single(snapshot.Profile.Summary));
|
||||
Assert.Equal("https://github.com/existing", snapshot.Profile.Contact.GitHub);
|
||||
Assert.Equal("Preserve my custom fact", Assert.Single(Assert.Single(snapshot.Profile.OtherSections).Items));
|
||||
}
|
||||
private const string Owner = "rd21-owner";
|
||||
private static ProfileCvController Controller(JobTrackerContext db, bool identitySucceeds = true)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user