-
Notifications
You must be signed in to change notification settings - Fork 250
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
Adds tests to cover ModuleContext.Close #407
Conversation
This backfills tests that ModuleContext.Close ends up calling `Store.CloseModule` and `SysContext.Close`. Signed-off-by: Adrian Cole <adrian@tetrate.io>
|
||
// We use side effects to determine if Close in fact called store.CloseModule (without repeating store_test.go). | ||
// One side effect of store.CloseModule is that the moduleName can no longer be looked up. Verify our base case. | ||
require.Equal(t, s.Module(moduleName), m) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nullpo-head here's an example of using other tests to build higher level signals that something happened.
For example, through this and other tests, we know that Module.Close()
ends up resulting in runtime.Module(moduleName) == nil
(provided you check the base case). This can lead to simpler tests when we are trying to see if a function that calls close executed. e.g. try to lookup the module it was called from.
require.Empty(t, sys.openedFiles) | ||
|
||
// Verify it was actually closed, by trying to close it again. | ||
err = file.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another side-effect you can use. Ex. if you can't easily reach the store or the runtime.. if you can open a file, you can check that it closed, by trying to close it again!
require.NoError(t, sys.Close()) | ||
}) | ||
|
||
// TODO: fs but never used (ex file == nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't be addressing these TODOs in this PR. This is just to unlock the other one. I'll do it in #394
thanks for the look! |
This backfills tests that ModuleContext.Close ends up calling
Store.CloseModule
andSysContext.Close
.