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

fix(4129): flaky event differ test #4165

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

elasticspoon
Copy link
Collaborator

@elasticspoon elasticspoon commented Mar 6, 2024

Resolves #4129

Minimal reproduction command:
rspec ./spec/events/event_differ_spec.rb[1:1] ./spec/models/inventory_item_spec.rb[1:1:1:3] --seed 32476

Crux of the matter is:

StorageLocation.count + 1 => EventTypes::EventStorageLocation.new(
    id: StorageLocation.count + 1,
    items: {}
    )

assumes that there will be 3 storage locations 1, 2, 3. If inventory_item_spec runs before, it creates a storage location. Thus, count will still be 3 but storage_location3 will have id 4.

Thus, storage_location3.id => stuff gets overridden by StorageLocation.count + 1 => stuff.

By changing the id of the nonexistent location to 0 we achieve the same test without a dependency on not having storage locations created before this test runs.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Minimal reproduction command:
rspec ./spec/events/event_differ_spec.rb[1:1] ./spec/models/inventory_item_spec.rb[1:1:1:3] --seed 32476

Crux of the matter is:
```rb
StorageLocation.count + 1 => EventTypes::EventStorageLocation.new(
    id: StorageLocation.count + 1,
    items: {}
    )
```
assumes that there will be 3 storage locations 1, 2, 3. If inventory_item_spec
runs before, it creates a storage location. Thus, count will still be 3
but storage_location3 will have id: 4.

Thus, storage_location3.id => stuff get overridden by StorageLocation.count + 1 => stuff.

By changing the id of the nonexistent location to 0 we achieve the same
test without a dependency on not having storage locations created before
this test runs.
Copy link
Collaborator

@dorner dorner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@dorner dorner merged commit b7e1ef5 into rubyforgood:main Mar 8, 2024
18 of 19 checks passed
@elasticspoon elasticspoon deleted the 4129-event-differ-flake branch March 8, 2024 20:45
Copy link
Contributor

@elasticspoon: Your PR fix(4129): flaky event differ test is part of today's Human Essentials production release: 2024.03.17.
Thank you very much for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: Flaky test spec/events/event_differ_spec.rb:16
2 participants