You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have found myself writing mocks for different map types but it is a bit painful; when trying to use new map types I get similar type conflicts, etc until I realize I need to mock more things, IDE is no longer helpful for docs and autocomplete of methods not yet implemented by my mocks, etc.
Maybe there is a better way like creating my own wrapper types I can more easily mock. Ultimately I still end up having to write my own mock implementations and I think this is likely a problem faced by others so I wanted to open this issue to discuss it.
However, this is only usable internally to the crate and when compiled to a test target. It would be really cool to expose something similar to make it easier to test for users of aya.
There are a few different ways around it but I am thinking the simplest and least intrusive could be a feature that users can enable for their tests that allows them to override syscalls. Going one step further, the creation of the maps themselves could be mocked appropriately.
The text was updated successfully, but these errors were encountered:
I have found myself writing mocks for different map types but it is a bit painful; when trying to use new map types I get similar type conflicts, etc until I realize I need to mock more things, IDE is no longer helpful for docs and autocomplete of methods not yet implemented by my mocks, etc.
Maybe there is a better way like creating my own wrapper types I can more easily mock. Ultimately I still end up having to write my own mock implementations and I think this is likely a problem faced by others so I wanted to open this issue to discuss it.
Example mock usage:
Example mock (quick and dirty):
Similar to #36
One thing I did notice was that tests inside aya leverage
test_utils
:aya/aya/src/maps/mod.rs
Lines 1040 to 1076 in a167554
which uses
override_syscall
:aya/aya/src/sys/fake.rs
Line 19 in a167554
Which is used as a mock here:
aya/aya/src/sys/mod.rs
Line 91 in a167554
However, this is only usable internally to the crate and when compiled to a test target. It would be really cool to expose something similar to make it easier to test for users of aya.
There are a few different ways around it but I am thinking the simplest and least intrusive could be a feature that users can enable for their tests that allows them to override syscalls. Going one step further, the creation of the maps themselves could be mocked appropriately.
The text was updated successfully, but these errors were encountered: