-
-
Notifications
You must be signed in to change notification settings - Fork 5
Minilcm diff API #1181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Minilcm diff API #1181
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
63a7a80
refactor diff code out of the sync service
hahn-kev f39073f
change terminiology
hahn-kev 99a8524
write test trying to sync changes between an entrys components
hahn-kev 0a01487
implement Component API
hahn-kev 33eb096
implement semantic domain API
hahn-kev c111134
GitButler WIP Commit
gitbutler-client 5947210
Merge branch 'develop' into Prep-diff-apis
hahn-kev a411b00
being making API to update an entry by simply passing it in
hahn-kev e03f1e7
add logging from MiniLcmApiFixture to xunit
hahn-kev f889baa
comment out version stuff and make a 2 entry update api for now
hahn-kev a4fb38c
Merge branch 'develop' into Prep-diff-apis
hahn-kev 804c8fa
remove version from entry
hahn-kev 2ccf0e2
fix some test bugs related to complex forms getting deleted and then …
hahn-kev f2c3eac
use locking to prevent a race condition from calling Project loader i…
hahn-kev 6228935
support syncing Entry.ComplexForms in addition to Components
hahn-kev 80fb4c3
define AddComplexFormType and RemoveComplexFormType on MiniLcmApi
hahn-kev 90c44b4
preseed complex form types in crdt projects
hahn-kev be5fa9e
implement syncing entry complex form types
hahn-kev 9d4611e
make complex form type a record
hahn-kev f783ca1
test creating an entry with a generated entry
hahn-kev f04794e
write sync tests for a generated entry, fix bugs
hahn-kev fb05ae7
update harmony to include the new `BeforeSaveObject` option
hahn-kev 2a4e139
add version to miniLcm models using CrdtConfig.BeforeSaveObject
hahn-kev 2c4119d
fix bug trying to use Commit.DateTime in a query
hahn-kev 8d7f5a6
implement UpdateEntry(Entry entry) on FwDataMiniLcmApi, then fix bugs
hahn-kev 356679d
remove unused fields
hahn-kev e402294
use the version to check for changes having been invalidated rather t…
hahn-kev ce07b24
minor fix suggestions
hahn-kev b900c5e
test CreateComplexFormComponent, fix a bug when there's more than one…
hahn-kev df91f0e
write test demonstrating update entry not supporting sense changes
hahn-kev 883984e
attempt to use get at commit api when updating an entry
hahn-kev 950f127
Merge branch 'develop' into minilcm-diff-apis
hahn-kev a90266c
always using DoUsingNewOrCurrentUOW as we've got a lot of recursive c…
hahn-kev 0a8fbef
simplify basic api tests to not special case different handling of en…
hahn-kev 9650ad5
allow defining copy which returns the correct type instead of IObject…
hahn-kev 11054f9
change use of GetEntitySnapshotAtTime to GetAtTime
hahn-kev 18cb5ee
exclude version from more tests
hahn-kev 57fe76c
change UpdateEntry to use before and after instead of depending on Ve…
hahn-kev 96c14b7
Merge branch 'develop' into minilcm-diff-apis
hahn-kev bb428cb
remove version property
hahn-kev c8e042f
fix test issue due to parts of speech and domains not being created w…
hahn-kev a4b97c6
Merge branch 'refs/heads/develop' into minilcm-diff-apis
hahn-kev 9a315be
exclude Semantic domain predefined due to it always being true in fwdata
hahn-kev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 3 additions & 1 deletion
4
backend/FwLite/FwDataMiniLcmBridge.Tests/MiniLcmTests/BasicApiTests.cs
This file contains hidden or 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
12 changes: 12 additions & 0 deletions
12
backend/FwLite/FwDataMiniLcmBridge.Tests/MiniLcmTests/UpdateEntryTests.cs
This file contains hidden or 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,12 @@ | ||
| using FwDataMiniLcmBridge.Tests.Fixtures; | ||
|
|
||
| namespace FwDataMiniLcmBridge.Tests.MiniLcmTests; | ||
|
|
||
| [Collection(ProjectLoaderFixture.Name)] | ||
| public class UpdateEntryTests(ProjectLoaderFixture fixture) : UpdateEntryTestsBase | ||
| { | ||
| protected override Task<IMiniLcmApi> NewApi() | ||
| { | ||
| return Task.FromResult<IMiniLcmApi>(fixture.NewProjectApi("update-entry-test", "en", "en")); | ||
| } | ||
| } |
This file contains hidden or 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
5 changes: 5 additions & 0 deletions
5
backend/FwLite/FwDataMiniLcmBridge/Api/VersionInvalidException.cs
This file contains hidden or 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,5 @@ | ||
| namespace FwDataMiniLcmBridge.Api; | ||
|
|
||
| public class VersionInvalidException(string type, Exception? innerException = null) : Exception( | ||
| $"version of {type} is invalid, it has been changed since this version was fetched", | ||
| innerException); |
This file contains hidden or 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
108 changes: 108 additions & 0 deletions
108
backend/FwLite/FwLiteProjectSync.Tests/EntrySyncTests.cs
This file contains hidden or 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,108 @@ | ||
| using FluentAssertions.Equivalency; | ||
| using FwLiteProjectSync.Tests.Fixtures; | ||
| using MiniLcm.Models; | ||
| using MiniLcm.SyncHelpers; | ||
| using MiniLcm.Tests.AutoFakerHelpers; | ||
| using Soenneker.Utils.AutoBogus; | ||
|
|
||
| namespace FwLiteProjectSync.Tests; | ||
|
|
||
| public class EntrySyncTests : IClassFixture<SyncFixture> | ||
| { | ||
| private readonly AutoFaker _autoFaker = new(builder => builder.WithOverride(new MultiStringOverride()).WithOverride(new ObjectWithIdOverride())); | ||
| public EntrySyncTests(SyncFixture fixture) | ||
| { | ||
| _fixture = fixture; | ||
| } | ||
|
|
||
| private readonly SyncFixture _fixture; | ||
|
|
||
| [Fact] | ||
| public async Task CanSyncRandomEntries() | ||
| { | ||
| var createdEntry = await _fixture.CrdtApi.CreateEntry(await _autoFaker.EntryReadyForCreation(_fixture.CrdtApi)); | ||
| var after = await _autoFaker.EntryReadyForCreation(_fixture.CrdtApi, entryId: createdEntry.Id); | ||
| await EntrySync.Sync(after, createdEntry, _fixture.CrdtApi); | ||
| var actual = await _fixture.CrdtApi.GetEntry(after.Id); | ||
| actual.Should().NotBeNull(); | ||
| actual.Should().BeEquivalentTo(after, options => options); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task CanChangeComplexFormVisSync_Components() | ||
| { | ||
| var component1 = await _fixture.CrdtApi.CreateEntry(new() { LexemeForm = { { "en", "component1" } } }); | ||
| var component2 = await _fixture.CrdtApi.CreateEntry(new() { LexemeForm = { { "en", "component2" } } }); | ||
| var complexFormId = Guid.NewGuid(); | ||
| var complexForm = await _fixture.CrdtApi.CreateEntry(new() | ||
| { | ||
| Id = complexFormId, | ||
| LexemeForm = { { "en", "complex form" } }, | ||
| Components = | ||
| [ | ||
| new ComplexFormComponent() | ||
| { | ||
| ComponentEntryId = component1.Id, | ||
| ComponentHeadword = component1.Headword(), | ||
| ComplexFormEntryId = complexFormId, | ||
| ComplexFormHeadword = "complex form" | ||
| } | ||
| ] | ||
| }); | ||
| Entry after = (Entry) complexForm.Copy(); | ||
| after.Components[0].ComponentEntryId = component2.Id; | ||
| after.Components[0].ComponentHeadword = component2.Headword(); | ||
|
|
||
| await EntrySync.Sync(after, complexForm, _fixture.CrdtApi); | ||
|
|
||
| var actual = await _fixture.CrdtApi.GetEntry(after.Id); | ||
| actual.Should().NotBeNull(); | ||
| actual.Should().BeEquivalentTo(after, options => options); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task CanChangeComplexFormViaSync_ComplexForms() | ||
| { | ||
| var complexForm1 = await _fixture.CrdtApi.CreateEntry(new() { LexemeForm = { { "en", "complexForm1" } } }); | ||
| var complexForm2 = await _fixture.CrdtApi.CreateEntry(new() { LexemeForm = { { "en", "complexForm2" } } }); | ||
| var componentId = Guid.NewGuid(); | ||
| var component = await _fixture.CrdtApi.CreateEntry(new() | ||
| { | ||
| Id = componentId, | ||
| LexemeForm = { { "en", "component" } }, | ||
| ComplexForms = | ||
| [ | ||
| new ComplexFormComponent() | ||
| { | ||
| ComponentEntryId = componentId, | ||
| ComponentHeadword = "component", | ||
| ComplexFormEntryId = complexForm1.Id, | ||
| ComplexFormHeadword = complexForm1.Headword() | ||
| } | ||
| ] | ||
| }); | ||
| Entry after = (Entry) component.Copy(); | ||
| after.ComplexForms[0].ComplexFormEntryId = complexForm2.Id; | ||
| after.ComplexForms[0].ComplexFormHeadword = complexForm2.Headword(); | ||
|
|
||
| await EntrySync.Sync(after, component, _fixture.CrdtApi); | ||
|
|
||
| var actual = await _fixture.CrdtApi.GetEntry(after.Id); | ||
| actual.Should().NotBeNull(); | ||
| actual.Should().BeEquivalentTo(after, options => options); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task CanChangeComplexFormTypeViaSync() | ||
| { | ||
| var entry = await _fixture.CrdtApi.CreateEntry(new() { LexemeForm = { { "en", "complexForm1" } } }); | ||
| var complexFormType = await _fixture.CrdtApi.GetComplexFormTypes().FirstAsync(); | ||
| var after = (Entry) entry.Copy(); | ||
| after.ComplexFormTypes = [complexFormType]; | ||
| await EntrySync.Sync(after, entry, _fixture.CrdtApi); | ||
|
|
||
| var actual = await _fixture.CrdtApi.GetEntry(after.Id); | ||
| actual.Should().NotBeNull(); | ||
| actual.Should().BeEquivalentTo(after, options => options); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.