Skip to content
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

Indexing Providers: Unit Tests #15601

Open
Skrypt opened this issue Mar 27, 2024 · 10 comments
Open

Indexing Providers: Unit Tests #15601

Skrypt opened this issue Mar 27, 2024 · 10 comments
Labels
enhancement Lucene Needs Unit Test(s) Unit Tests or Functional Tests are required P2
Milestone

Comments

@Skrypt
Copy link
Contributor

Skrypt commented Mar 27, 2024

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.

  1. Create a content item.
  2. Publish a content item.
  3. Save a draft of a content item.
  4. Remove a content items.

The "index latest" option of a Lucene index needs also to be unit tested against all these events.

@Skrypt Skrypt added enhancement Lucene Needs Unit Test(s) Unit Tests or Functional Tests are required labels Mar 27, 2024
@Piedone
Copy link
Member

Piedone commented Mar 27, 2024

How about the same for Elasticsearch?

@Skrypt Skrypt changed the title Lucene: Unit Tests Search Providers: Unit Tests Mar 27, 2024
@Skrypt Skrypt changed the title Search Providers: Unit Tests Indexing Providers: Unit Tests Mar 27, 2024
@sebastienros sebastienros added this to the 1.x milestone Mar 28, 2024
@hyzx86
Copy link
Contributor

hyzx86 commented May 2, 2024

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);

@hishamco
Copy link
Member

hishamco commented May 2, 2024

Why?

@hyzx86
Copy link
Contributor

hyzx86 commented May 2, 2024

You can try this PR~~

https://github.com/OrchardCMS/OrchardCore/pull/13721/files#r1587500147

Comment part of the code, cannot pass

@hyzx86
Copy link
Contributor

hyzx86 commented May 2, 2024

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);

@hishamco
Copy link
Member

hishamco commented May 2, 2024

I will have a look if I have a time

@hyzx86
Copy link
Contributor

hyzx86 commented May 2, 2024

Without calling PublishAsync, we wouldn't even be able to find it from the database
image

@hishamco
Copy link
Member

hishamco commented May 2, 2024

This is a unit test, right? no database interaction

@hyzx86
Copy link
Contributor

hyzx86 commented May 2, 2024

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

@Piedone Piedone modified the milestones: 2.x, 2.1 May 3, 2024
@MikeAlhayek MikeAlhayek modified the milestones: 2.1, 2.x Nov 12, 2024
Copy link
Contributor

We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).

This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.

@MikeAlhayek MikeAlhayek added the P2 label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Lucene Needs Unit Test(s) Unit Tests or Functional Tests are required P2
Projects
None yet
Development

No branches or pull requests

6 participants