Files
gitocean/modules
Earl Warren 884b3c0f4b test(util): MockProtect when mocking multiple times
It is fine to use MockVariableValue to change a setting such as:

defer test.MockVariableValue(&setting.Mirror.Enabled, true)()

But when testing for errors and mocking a function, multiple variants
of the functions will be used, not just one. MockProtect a function
will make sure that when the test fails it always restores a sane
version of the function. For instance:

defer test.MockProtect(&mirror_service.AddPushMirrorRemote)()

mirror_service.AddPushMirrorRemote = mockOne
do some tests that may fail

mirror_service.AddPushMirrorRemote = mockTwo
do more tests that may fail
2024-06-02 15:24:06 +02:00
..
2024-05-14 08:24:31 +02:00
2023-12-19 09:29:05 +00:00
2024-05-29 18:31:06 +02:00
Fix
2024-03-30 15:23:48 +01:00
2023-02-11 08:39:50 +08:00
2023-12-25 20:13:18 +08:00
2024-05-21 18:02:37 +02:00
2022-12-30 23:31:00 +08:00
2023-11-03 15:21:05 +00:00
2024-05-24 13:28:15 +02:00
2024-05-14 08:31:34 +02:00
2024-04-05 10:20:40 +02:00