• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lpenz / ogle / 13188321022

06 Feb 2025 09:33PM UTC coverage: 55.118% (-0.9%) from 55.968%
13188321022

push

github

lpenz
sys_api.rs: new abstraction for external function to allow better testing

For now we are only abstracting "now()"

10 of 17 new or added lines in 5 files covered. (58.82%)

210 of 381 relevant lines covered (55.12%)

1.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

42.86
/src/sys_api.rs
1
// Copyright (C) 2025 Leandro Lisboa Penz <lpenz@lpenz.org>
2
// This file is subject to the terms and conditions defined in
3
// file 'LICENSE', which is part of this source code package.
4

5
use mockall::automock;
6

7
use crate::time_wrapper::Instant;
8

NEW
9
#[automock]
×
10
pub trait SysApi {
11
    fn now() -> Instant;
12
}
13

14
#[derive(Default, Debug)]
15
pub struct Sys {}
16

17
impl Sys {
18
    pub fn now() -> Instant {
2✔
19
        Instant::from(chrono::offset::Utc::now())
2✔
20
    }
2✔
21
}
22

23
impl SysApi for Sys {
NEW
24
    fn now() -> Instant {
×
NEW
25
        Sys::now()
×
NEW
26
    }
×
27
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc