Open Skrypt opened 3 months ago
How about the same for Elasticsearch?
It looks like we can't test the Created function alone In my tests, they are not even saved to the database.
await contentManager.CreateAsync(firstContent);
var contentFromDb = await contentManager.GetAsync(firstContent.ContentItemId);
Assert.NotNull(contentFromDb);
Why?
You can try this PR~~
https://github.com/OrchardCMS/OrchardCore/pull/13721/files#r1587500147
Comment part of the code, cannot pass
We have to create content like this
await contentManager.UpdateValidateAndCreateAsync(firstContent, VersionOptions.Draft);
await contentManager.PublishAsync(firstContent);
var contentFromDb = await contentManager.GetAsync(firstContent.ContentItemId);
Assert.NotNull(contentFromDb);
I will have a look if I have a time
Without calling PublishAsync, we wouldn't even be able to find it from the database
This is a unit test, right? no database interaction
Indeed in unit testing,
The test context is BlogContext,
which should use the Sqlite
database.
If I call PublishAsync
, then this object can be retrieved from the database
The Lucene unit tests are not covering all use cases. We are missing unit tests for the LuceneIndexingContentHandler and all the events that are possible.
The "index latest" option of a Lucene index needs also to be unit tested against all these events.