It would be quite useful for tests if _TestingPebbleClient's mocked file operations also saved a map of the intended metadata and returned the intended metadata for operations that request it.
In particular, it would be helpful for testing cases where metadata such as file ownership or permissions matter and are being checked, as we otherwise need to mock it ourselves.
To give a more concrete example, if we have behavior dependent on the return from charmlibs.pathops's ensure_contents, and we want to ensure a file with a particular user/group/set of permissions, in unit test scenarios, it will never match because we are otherwise checking against the metadata from the host file system.
It would be quite useful for tests if
_TestingPebbleClient's mocked file operations also saved a map of the intended metadata and returned the intended metadata for operations that request it.In particular, it would be helpful for testing cases where metadata such as file ownership or permissions matter and are being checked, as we otherwise need to mock it ourselves.
To give a more concrete example, if we have behavior dependent on the return from
charmlibs.pathops'sensure_contents, and we want to ensure a file with a particular user/group/set of permissions, in unit test scenarios, it will never match because we are otherwise checking against the metadata from the host file system.