test(battery): add battery tests (#2795)

Add some tests to the battery module, make it testable by mocking out the code that fetches battery info.
This commit is contained in:
Andrew Houts
2021-06-29 18:46:41 -05:00
committed by GitHub
parent 72e5a544fc
commit 53a30046d1
6 changed files with 423 additions and 41 deletions
+9
View File
@@ -121,6 +121,15 @@ impl<'a> ModuleRenderer<'a> {
self
}
#[cfg(feature = "battery")]
pub fn battery_info_provider(
mut self,
battery_info_provider: &'a (dyn crate::modules::BatteryInfoProvider + Send + Sync),
) -> Self {
self.context.battery_info_provider = battery_info_provider;
self
}
/// Renders the module returning its output
pub fn collect(self) -> Option<String> {
let ret = crate::print::get_module(self.name, self.context);