Skip to content
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

Fix failing doc tests #123

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ jobs:
# * clippy --all-targets causes clippy to run against tests and examples which it doesnt do by default.
run: cargo hack --feature-powerset clippy --all-targets --locked ${{ matrix.cargo_flags }} -- -D warnings
- name: Ensure that tests pass
run: cargo test ${{ matrix.cargo_flags }} --all-features --all-targets -- --nocapture
run: |
cargo test --doc ${{ matrix.cargo_flags }} --all-features -- --show-output --nocapture
cargo test ${{ matrix.cargo_flags }} --all-features --all-targets -- --nocapture
- name: Ensure that tests did not create or modify any files that arent .gitignore'd
run: |
if [ -n "$(git status --porcelain)" ]; then
Expand Down
2 changes: 1 addition & 1 deletion prometheus-remote/src/lib_vsri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub struct Vsri {
impl Vsri {
/// Creates the index, it doesn't create the file in the disk
/// flush needs to be called for that
pub fn new(filename: &String) -> Self {
pub fn new(filename: &str) -> Self {
debug!("[INDEX] Creating new index!");
let segments: Vec<[i32; 4]> = Vec::new();
Vsri {
Expand Down
18 changes: 11 additions & 7 deletions vsri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,22 @@ pub fn start_day_ts(dt: DateTime<Utc>) -> i64 {
/// # Examples
/// Creating a new index, metric is of expected time 0, but for sure location of X is 0
/// ```no_run
/// let vsri = Vsri::new("metric_name", 0, 0);
/// # use vsri::Vsri;
/// let vsri = Vsri::new("metric_name");
/// vsri.flush();
/// ```
/// Updating an index, adding point at time 5sec
/// ```no_run
/// let vsri = Vsri::load("metric_name").unwrap().update_for_point(5);
///
/// # use vsri::Vsri;
/// let mut vsri = Vsri::load("metric_name").unwrap();
/// vsri.update_for_point(5).unwrap();
/// vsri.flush();
/// ```
/// Fetch a sample location from the index given a timestamp
/// ```no_run
/// let vsri = Vsri::load("metric_name").unwrap();
/// vsri.get_sample_location("metric_name", 5);
/// # use vsri::Vsri;
/// let vsri = Vsri::get_sample_location("metric_name", 5);
/// ```

/// Index Structure
Expand All @@ -90,7 +94,7 @@ pub struct Vsri {
impl Vsri {
/// Creates the index, it doesn't create the file in the disk
/// flush needs to be called for that
pub fn new(filename: &String) -> Self {
pub fn new(filename: &str) -> Self {
debug!("[INDEX] Creating new index!");
Vsri {
index_file: filename.to_string(),
Expand All @@ -102,8 +106,8 @@ impl Vsri {

/// Given a filename and a time location, returns the sample location in the
/// data file. Or None in case it doesn't exist.
pub fn get_sample_location(filename: String, y: i32) -> Option<i32> {
let vsri = match Vsri::load(&filename) {
pub fn get_sample_location(filename: &str, y: i32) -> Option<i32> {
let vsri = match Vsri::load(filename) {
Ok(vsri) => vsri,
Err(_err) => return None,
};
Expand Down
Loading