foundry icon indicating copy to clipboard operation
foundry copied to clipboard

createMany and createOne or new->create does not work well together on the CI

Open benblub opened this issue 2 years ago • 3 comments

        EmbeddedContentFactory::createMany(5);
        EmbeddedContentFactory::createMany(3, ['type' => EmbeddedContentType::CantonNavigation]);
        EmbeddedContentFactory::createOne(['title' => 'Exact title', 'type' => EmbeddedContentType::Fixture]);

        $this->assertCount(9, EmbeddedContentFactory::repository()->findAll(), 'Expected 9 embedded contents');

This is failing in CI/Github actions = Failed asserting that actual size 8 matches expected size 9.

What is working

        EmbeddedContentFactory::createMany(
            6,
            static function (int $i) {
                if ($i === 1) {
                    return ['title' => 'Exact title', 'type' => EmbeddedContentType::Fixture];
                }

                return ['title' => "Title $i"];
            }
        );
        EmbeddedContentFactory::createMany(3, ['type' => EmbeddedContentType::CantonNavigation]);

        $this->assertCount(9, EmbeddedContentFactory::repository()->findAll(), 'Expected 9 embedded contents');

I trying to understand what the problem can be but since its working local its hard to debug. Did someone know or can lead me the right direction? Not sure this is a bug ..

Additional: DAMA is used, the code is failing early without other code involved.

benblub avatar Jul 21 '23 07:07 benblub

fun fact

If I switch the order there is no error raised

        EmbeddedContentFactory::createOne(['title' => 'Exact title', 'type' => EmbeddedContentType::Fixture]);
        EmbeddedContentFactory::createMany(5);
        EmbeddedContentFactory::createMany(3, ['type' => EmbeddedContentType::CantonNavigation]);

        $this->assertCount(9, EmbeddedContentFactory::repository()->findAll(), 'Expected 9 embedded contents');

benblub avatar Jul 21 '23 09:07 benblub

Hi @benblub

sorry I have no clue why this is happening. I bet this is not related to Foundry, but not really sure. The "fun fact" is really weird :exploding_head:

Maybe if you can create a public reproducer I could give a hand.

I recently heard about https://github.com/mxschmitt/action-tmate which can help to debug your actions by ssh-ing on the runners, maybe this could help!

nikophil avatar Jul 21 '23 13:07 nikophil

ok will take a look by time, thx

benblub avatar Jul 27 '23 15:07 benblub

I'm closing this stale issue. feel free to reopen :)

nikophil avatar Jun 23 '24 16:06 nikophil